WMENCODEPROC callback
Encoded data processing callback function.
void CALLBACK WMEncodeProc( HWMENCODE handle, DWORD type, const void *buffer, DWORD length, void *user );
Parameters
handle | The encoder handle. | ||||||
type | The type of data to process, one of the following.
| ||||||
buffer | A pointer to the data to process. | ||||||
length | The length of the data. | ||||||
user | The user instance data given when BASS_WMA_EncodeOpen was called. |
Remarks
When encoding begins, an initial header is given. When encoding is completed, an updated header is given (with the duration info, etc). When encoding to a file (whether that is on disk or not), the initial header should be replaced by the updated one.Example
A callback function to encode to a file.void CALLBACK MyWMEncodeProc(HWMENCODE handle, DWORD type, const void *buffer, DWORD length, void *user) { if (type==BASS_WMA_ENCODE_HEAD) { fseek(user, 0, SEEK_SET); // rewind to start of file fwrite(buffer, length, 1, user); // write the header } else if (type==BASS_WMA_ENCODE_DATA) fwrite(buffer, length, 1, user); // write encoded data else if (type==BASS_WMA_ENCODE_DONE) fclose(user); // done encoding - close the file } ... FILE *file=fopen("a_file.wma", "wb"); // created the file BASS_WMA_EncodeOpen(44100, 2, 0, 64000, &MyWMEncodeProc;, file); // create the encoder
NOTE: This is just an example. It is simpler to use BASS_WMA_EncodeOpenFile to encode to a file.