GePlaySnd Class Reference Library » Sound

#include <lib_snd.h>

详细描述

A class for playing sounds.

注意
Has to be created with Alloc() and destroyed with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

Normally one want to use the BaseSound class for the actual sound, as in this example:

Filename fn; if (!fn. FileSelect ( FILESELECTTYPE::ANYTHING , FILESELECT::LOAD , "Load Sound" )) return false ;
AutoAlloc<BaseSound> sound; if (!sound) return false ; if (!sound-> Load (fn)) return false ; GeSndInfo sndinfo(sound); AutoAlloc<GePlaySnd> playsound; if (!playsound) return false ; playsound-> Open (sound); playsound-> Scrub (0, sndinfo.GetLength().Get()); while (playsound-> IsPlaying ()) { GePrint ( "pos: " + String::FloatToString (playsound-> GetPositionEstimate ())); } playsound-> 关闭 ();

私有成员函数

  GePlaySnd ()
  ~GePlaySnd ()

Alloc/Free

static GePlaySnd Alloc ()
static void  Free ( GePlaySnd *&data)

杂项

Bool   Open (const BaseSound *snd)
Bool   Open ( Int32 stream_cnt, const BaseSound **streams, const Float *start_offsets, Float max_length)
void  关闭 (void)
void  StartAt ( Float64 start)
void  Scrub ( Float64 start, Float64 duration)
void  Stop (void)
Bool   IsPlaying (void)
Float64   GetPositionEstimate (void)
void  SetScale ( Float64 scale)
Float64   GetScale (void)

构造函数 & 析构函数文档编制

◆  GePlaySnd()

GePlaySnd () private

◆  ~GePlaySnd()

~ GePlaySnd () private

成员函数文档编制

◆  Alloc()

static GePlaySnd * Alloc ( )
static

Allocates a GePlaySnd instance. Destroy the allocated GePlaySnd instance with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

返回
The allocated GePlaySnd instance, or nullptr if the allocation failed.

◆  Free()

static void Free ( GePlaySnd *&  data )
static

Destructs GePlaySnd instances allocated with Alloc() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

参数
[in,out] data The GePlaySnd instance to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆  Open() [1/2]

Bool Open ( const BaseSound snd )

The audio data referenced by the BaseSound will be kept in memory until Close() is called.

参数
[in] snd The sound to use for playback. The caller owns the pointed sound.
返回
true if successful, otherwise false .

◆  Open() [2/2]

Bool Open ( Int32   stream_cnt ,
const BaseSound **  streams ,
const Float start_offsets ,
Float   max_length  
)

Opens an audio device with multiple BaseSounds that will be mixed. The audio data referenced by the BaseSounds will be kept in memory until Close() is called.

参数
[in] stream_cnt The number of sounds to be mixed.
[in] streams The array with the sounds.
[in] start_offsets The array with start time offsets in seconds (this is the audible sound data when StartAt(0) is called).
[in] max_length The maximum length of the audio data in seconds (relative to StartAt(0) ).
返回
true if successful, otherwise false .

◆  Close()

void Close ( void  )

Closes the audio device.

注意
If the sounds used for Open() have been deleted in the meantime, their audio data will be released.

◆  StartAt()

void StartAt ( Float64   start )

Starts audio output.

参数
[in] start The position relative to the start of the audio data in seconds.

◆  Scrub()

void Scrub ( Float64   start ,
Float64   duration  
)
参数
[in] start The position relative to the start of the audio data in seconds.
[in] duration The scrub duration in seconds after which the audio device will be stopped.

◆  Stop()

void Stop ( void  )

Stops audio output.

◆  IsPlaying()

Bool IsPlaying ( void  )

Checks if the audio device is running

返回
true if if audio is playing, otherwise false .

◆  GetPositionEstimate()

Float64 GetPositionEstimate ( void  )

Gets an estimate audio position.

返回
The currently audible position in seconds.

◆  SetScale()

void SetScale ( Float64   scale )

Sets the playback time scale.

参数
[in] scale The playback scale value: 1.0 means real time, 2.0 means twice as fast, 0.5 means half the speed, 0.0 is invalid.

◆  GetScale()

Float64 GetScale ( void  )

Gets the current playback time scale.

返回
The playback scale value: 1.0 means real time, 2.0 means twice as fast, 0.5 means half the speed, 0.0 is invalid.
String::FloatToString
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
定义: c4d_string.h:529
GeSndInfo
定义: lib_snd.h:29
GePlaySnd::IsPlaying
Bool IsPlaying(void)
Filename
Manages file and path names.
定义: c4d_file.h:93
GePlaySnd::Scrub
void Scrub(Float64 start, Float64 duration)
FILESELECTTYPE::ANYTHING
@ ANYTHING
Any file.
GePlaySnd::Close
void Close(void)
GePrint
void GePrint(const maxon::String &str)
GePlaySnd::GetPositionEstimate
Float64 GetPositionEstimate(void)
FILESELECT::LOAD
@ LOAD
Load dialog.
BaseSound::Load
Bool Load(const Filename &fn)
AutoAlloc
定义: ge_autoptr.h:36
GePlaySnd::Open
Bool Open(const BaseSound *snd)
Filename::FileSelect
Bool FileSelect(FILESELECTTYPE type, FILESELECT flags, const maxon::String &title, const maxon::String &force_suffix=maxon::String())