I am trying to read in one WMA file, 44.1, stereo, 16 bit, 114kbps Bit Rate.
I want to encode that file out as a WMA, 22.05, mono, 16 bit, 20 k bit rate.
I have the following code working, but it outputs a file that is really slow, and 4 times the length of the original. The settings on the file are correct at 22.05, 20k, etc.
I thought the BASS_ChannelGetData would return me RAW PCM, and then the BASS_WMA_EncodeWrite would be able to encode that. But maybe that assumption is incorrect.
Any help would be great.
Bass.BASS_Init(0,44100,BASSInit.BASS_DEVICE_DEFAULT, 0, null);
_WMstream = BassWma.BASS_WMA_StreamCreateFile(inputFile, 0, 0, BASSStream.BASS_STREAM_DECODE);
int channels = 1;
_EncoderStream = BassWma.BASS_WMA_EncodeOpenFile(Frequency, channels, BASSWMAEncode.BASS_WMA_ENCODE_DEFAULT, Bitrate, outputFile);
fileLength=Bass.BASS_ChannelGetLength(_WMstream);
float seconds=Bass.BASS_ChannelBytes2Seconds(_WMstream,fileLength);
byte[] tempArray=new byte[20000];
while((Bass.BASS_ChannelIsActive(_WMstream)==(int)BASSActive.BASS_ACTIVE_PLAYING) && !cancelling)
{
int temp=Bass.BASS_ChannelGetData(_WMstream,tempArray,20000);
currentPosition=Bass.BASS_ChannelGetPosition(_WMstream);
if (!BassWma.BASS_WMA_EncodeWrite(_EncoderStream, tempArray, 20000))
{
// there was some sort of error
}
int currentPercentCompute=(int)(((float)currentPosition/(float)fileLength)*100);
if(percentComplete!=currentPercentCompute)
{
// update display }
}
}
BassWma.BASS_WMA_EncodeClose(_EncoderStream);
BassEnc.BASS_Encode_Stop(_WMstream);
Bass.BASS_Free();