How to export the loaded song into a WAV file |
|
If you need to perform a specific analysis of a sound loaded inside a player, the best thing to do is to have it available in uncompressed WAV format: for this purpose, the container application can choose to export the sound to a WAV file on hard-disk or in memory. It's important to note that the exported WAV file will not be resampled at all so it will have the same sample rate and number of channels of the loaded sound file; if you should need to perform a resampling you should consider using the ExportToFile method of our Audio Sound Editor API for .NET component in place of Audio Dj Studio API for .NET.
The first thing to do is calling the RequestSoundExportToWav method: this method has a strPathname parameter were you can specify the full pathname of the output disk file in WAV format or, if the parameter is left empty, the exported WAV file will be stored inside a memory buffer.
Depending upon the size of the loaded sound, the export session could result in a lengthy operation so it will be performed on a separate thread: during the export session, the container application will be notified about the exporting advancement through through the CallbackForPlayersEvents delegate which is invoked with the nEvent parameter set to:
• | EV_WAV_EXPORT_START invoked once at the beginning |
• | EV_WAV_EXPORT_PERC invoked multiple times reporting the current advancement percentage inside the nData1 parameter |
• | EV_WAV_EXPORT_COMPLETE invoked as soon as the exporting session is completed |
As you will understand, the EV_WAV_EXPORT_COMPLETE event will notify the container application about the exported WAV file availability and will report, inside the nData1 parameter, the effective size in bytes used to store the WAV file; if the exported WAV file has been stored on a hard-disk file, you will have the possibility to access its contents through the file access functions allowed by your development environment; if the exported WAV file has been stored in memory, you will have the possibility to copy the file contents into a buffer allocated by the container application through a call to the CopyExportedWavToMemory method: in this last case, it's important to note that after calling the CopyExportedWavToMemory method the original memory buffer, internal to the control and containing the exported WAV file, will be discarded from memory so it won't be accessible for further copies.