Contents Up Previous Next

wxSoundFileStream

Base class for file coders/decoders. This class is not constructor (it is an abstract class).

Derived from

wxSoundStream

Include file

wx/sndfile.h

Data structures

Members

wxSoundFileStream::wxSoundFileStream
wxSoundFileStream::~wxSoundFileStream
wxSoundFileStream::Play
wxSoundFileStream::Record
wxSoundFileStream::Stop
wxSoundFileStream::Pause
wxSoundFileStream::Resume
wxSoundFileStream::IsStopped
wxSoundFileStream::IsPaused
wxSoundFileStream::StartProduction
wxSoundFileStream::StopProduction
wxSoundFileStream::GetLength
wxSoundFileStream::GetPosition
wxSoundFileStream::SetPosition
wxSoundFileStream::Read
wxSoundFileStream::Write
wxSoundFileStream::SetSoundFormat
wxSoundFileStream::GetCodecName
wxSoundFileStream::CanRead
wxSoundFileStream::PrepareToPlay
wxSoundFileStream::PrepareToRecord
wxSoundFileStream::FinishRecording
wxSoundFileStream::RepositionStream
wxSoundFileStream::FinishPreparation
wxSoundFileStream::GetData
wxSoundFileStream::PutData


wxSoundFileStream::wxSoundFileStream

wxSoundFileStream(wxInputStream& stream, wxSoundStream& io_sound)

It constructs a new file decoder object which will send audio data to the specified sound stream. The stream is the input stream to be decoded. The io_sound is the destination sound stream. Once it has been constructed, you cannot change any of the specified streams nor the direction of the stream.

You will have access to the playback functions.

wxSoundFileStream(wxOutputStream& stream, wxSoundStream& io_sound)

It constructs a new file coder object which will get data to be recorded from the specified sound stream. The stream is the output wxStream. The io_sound is the source sound stream of the audio data. Once it has been constructed, you cannot change any of the specified streams nor the direction of the stream.


wxSoundFileStream::~wxSoundFileStream

~wxSoundFileStream()

It destroys the current sound file codec.


wxSoundFileStream::Play

bool Play()

It starts playing the file. The playing begins, in background in nearly all cases, after the return of the function. The codec returns to a stopped state when it reaches the end of the file. On success, it returns TRUE.


wxSoundFileStream::Record

bool Record(wxUint32 time)

It starts recording data from the sound stream and writing them to the output stream. You have to precise the recording length in parameter. This length is expressed in seconds. If you want to control the record length (using Stop), you can set it to wxSOUND_INFINITE_TIME.

On success, it returns TRUE.


wxSoundFileStream::Stop

bool Stop()

It stops either recording or playing. Whatever happens (even unexpected errors), the stream is stopped when the function returns. When you are in recording mode, the file headers are updated and flushed if possible (ie: if the output stream is seekable).

On success, it returns TRUE.


wxSoundFileStream::Pause

bool Pause()

The file codec tries to pause the stream: it means that it stops audio production but keep the file pointer at the place.

If the file codec is already paused, it returns FALSE.

On success, it returns TREE.


wxSoundFileStream::Resume

bool Resume()

When the file codec has been paused using Pause, you could be interrested in resuming it. This is the goal of this function.


wxSoundFileStream::IsStopped

bool IsStopped() const

It returns TRUE when the stream is stopped, in another case it returns FALSE.


wxSoundFileStream::IsPaused

bool IsPaused() const

It returns TRUE when the stream is paused, in another case it returns FALSE.


wxSoundFileStream::StartProduction

bool StartProduction(int evt)

It is really not advised you call this function. From the wxSoundFileStream point of view it is an internal function. Internally, it is called after the file stream has been prepared to be played or to receive audio data and when it wants to start processing audio data.


wxSoundFileStream::StopProduction

bool StopProduction()

As for StartProduction, it is not advised for you to call this function. It is called by Stop when it needs to stop the audio data processing.


wxSoundFileStream::GetLength

wxUint32 GetLength()

It returns the audio data length of the file stream. This length is expressed in bytes. If you need the length in seconds, you will need to use GetSoundFormat and GetTimeFromBytes.


wxSoundFileStream::GetPosition

wxUint32 GetPosition()

It returns the current position in the soundfile stream. The position is expressed in bytes. If you need the length in seconds, you will need to use GetSoundFormat and GetTimeFromBytes.


wxSoundFileStream::SetPosition

wxUint32 SetPosition(wxUint32 new_position)

It sets the current in the soundfile stream. The position new_position must be expressed in bytes. You can get a length/position in bytes from a time value using GetSoundFormat and GetTimeFromBytes.

On success, it returns TRUE.

Warning

Some wxStream may not be capable to support this function as it may not support the seekable functionnality. If this happens, it returns FALSE and leave the stream at the same position.


wxSoundFileStream::Read

wxSoundStream& Read(void* buffer, wxUint32 len)

You can obtain the audio data encoded in the file using this function. But it must be considered as an internal function. Used carelessly, it may corrupt the current state of the stream. Data are returned using in the original file coding (You must use a sound format object to decode it).


wxSoundFileStream::Write

wxSoundStream& Write(const void* buffer, wxUint32 len)

You can put encoded audio data to the file using this function. But it must be considered as an internal function. Used carelessly, it may corrupt the current state of the stream. Data must be coded with the specified file coding (You must use a sound format object to do this).


wxSoundFileStream::SetSoundFormat

bool SetSoundFormat(const wxSoundFormatBase& format)


wxSoundFileStream::GetCodecName

wxString GetCodecName() const

This function returns the Codec name. This is useful for those who want to build a player (But also in some other case).


wxSoundFileStream::CanRead

bool CanRead()

You should use this function to test whether this file codec can read the stream you passed to it.


wxSoundFileStream::PrepareToPlay

bool PrepareToPlay()

It is called by wxSoundFileStream to prepare the specific file loader to prepare itself to play the file. Actually, this includes reading headers and setting the various parameters of the sound format. This should not be called by an external user but it should be implemented when you inherit wxSoundFileStream to build a new codec.

It must return when the file is identified and the parameters have been set. In all other cases, you must return FALSE.


wxSoundFileStream::PrepareToRecord

bool PrepareToRecord(wxUint32 time)


wxSoundFileStream::FinishRecording

bool FinishRecording()


wxSoundFileStream::RepositionStream

bool RepositionStream(wxUint32 position)

This is called by wxSoundFileStream::SetPosition to seek the input stream to the right position. This must be overidden by the file codec class. The position is relative to the beginning of the samples. If it is impossible (as for a piped input stream), you must return FALSE.


wxSoundFileStream::FinishPreparation

void FinishPreparation(wxUint32 len)

This is an internal function but it must called by the file codec class when the "playing" preparation is finished and you know the size of the stream. If it is an infinite stream, you should set this to wxSOUND_INFINITE_TIME.


wxSoundFileStream::GetData

wxUint32 GetData(void* buffer, wxUint32 len)

This is called by wxSoundFileStream when it needs to get new sound data to send to the device driver (or to a conversion codec). This must be eventually overidden by the file codec class. The default behaviour is simply to read from the input stream.


wxSoundFileStream::PutData

wxUint32 PutData(const void* buffer, wxUint32 len)

This is called by wxSoundFileStream when it needs to put new sound data received from the device driver (or from a conversion codec). This must be eventually overidden by the file codec class. The default behaviour is simply to write to the input stream.