Bernd,
i simply can't make it work.
using the program below doesn't produce any output. Also tried without an Encoding Proc and specified the file name, with the same result.
commenting the enc_aacplus line and use lame, i get a perfect rip of the first track of the CD.
it's just that enc_aacplus does nothing. (Of course, i have enc_aacplus.dll and nscrt.dll in my executable folder).
Also, one other question. how does that work with the --mp4box switch? Can this switch be used together with stdout and an encoing proc?
thanks,
Helmut
using System;
using System.Runtime.InteropServices;
using Un4seen.Bass;
using Un4seen.Bass.AddOn.Enc;
using Un4seen.Bass.AddOn.Cd;
namespace EncTest
{
class Program
{
private static ENCODEPROC _encoderProc;
private static string _outFile;
private static System.IO.FileStream _fs = null;
private static byte[] _data = new byte[1048510]; // 1MB buffer
static void Main(string[] args)
{
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, null);
int stream = BassCd.BASS_CD_StreamCreate(0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_DEFAULT);
_outFile = "Track1.aac";
string encoderSettings = "enc_aacplus.exe - - --cbr 128000";
//string encoderSettings = "lame --preset standard - -";
_encoderProc = new ENCODEPROC(EncoderSave);
int encoderHandle = BassEnc.BASS_Encode_Start(stream, encoderSettings, BASSEncode.BASS_ENCODE_DEFAULT, _encoderProc, IntPtr.Zero);
byte[] encBuffer = new byte[1048510]; // our encoding buffer
while (Bass.BASS_ChannelIsActive(stream) == BASSActive.BASS_ACTIVE_PLAYING)
{
// getting sample data will automatically feed the encoder
int len = Bass.BASS_ChannelGetData(stream, encBuffer, encBuffer.Length);
}
BassEnc.BASS_Encode_Stop(stream);
Bass.BASS_StreamFree(stream);
if (_fs != null)
{
_fs.Flush();
_fs.Close();
}
}
private static void EncoderSave(int handle, int channel, IntPtr buffer, int length, IntPtr user)
{
if (_fs == null)
{
_fs = System.IO.File.OpenWrite(_outFile);
}
if (buffer != IntPtr.Zero)
{
Marshal.Copy(buffer, _data, 0, length);
_fs.Write(_data, 0, length);
}
}
}
}