I have a problem with digigram driver for VX442e card. This app should encode/decode strema for VOIP purposes.
As I need sample freq of 8 khz, I try to initialize inputs and outputs with 8000 sample rate.
It works for outputs (card nicely play audio), but when I try to initialze inputs (ChannelSetRatee(true, Globali.Line1InAudioChannel, 8000d),
app hangs, and driver stop to function until computer reset. If I use Asio4All driver with onboard audio card everything works fine.
I appreciate any idea, or am I trying something wrong ?
Thanks !
public void StartAudioCards()
{
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0);
Bass.BASS_Init(-1, 48000, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
BassAsio.BASS_ASIO_Init(0, BASSASIOInit.BASS_ASIO_DEFAULT);
BASS_ASIO_INFO info = new BASS_ASIO_INFO();
BassAsio.BASS_ASIO_GetInfo(info);
BassAsio.BASS_ASIO_SetRate(48000d);
//-BEGIN-----------------------------------------------------------Define audio output
PushOut[0] = Bass.BASS_StreamCreatePush( Convert.ToInt32(Globali.OutputSampleFreq) , 1,
BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_8BITS,
IntPtr.Zero);
AsioOut[0] = new BassAsioHandler(false, 0, Globali.Line1OutAudioChannel, 1, BASSASIOFormat.BASS_ASIO_FORMAT_16BIT, Convert.ToInt32(Globali.OutputSampleFreq));
AsioOut[0].OutputChannel = PushOut[0];
BassAsio.BASS_ASIO_ChannelSetRate(false, 0, 8000); // 8000 je sample rate iz odabranog codeca
BassAsio.BASS_ASIO_ChannelSetFormat(false, Globali.Line1OutAudioChannel, BASSASIOFormat.BASS_ASIO_FORMAT_16BIT);
//-END-----------------------------------------------------------Define audio output
//-BEGIN-----------------------------------------------------------Define audio input
PushIn[0] = Bass.BASS_StreamCreatePush(8000, 1,
BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_8BITS | BASSFlag.BASS_SAMPLE_MONO,
IntPtr.Zero); //postavljamo Push stream kao 1 kanalni stream
BassAsio.BASS_ASIO_ChannelSetFormat(true, Globali.Line1InAudioChannel, BASSASIOFormat.BASS_ASIO_FORMAT_16BIT);
BassAsio.BASS_ASIO_ChannelSetRate(true, Globali.Line1InAudioChannel, 8000d);
MyAsioProcCh0 = new ASIOPROC(AsioInputCallbackCh0);
BassAsio.BASS_ASIO_ChannelEnable(true, Globali.Line1InAudioChannel, MyAsioProcCh0, new IntPtr(PushIn[0]));
//-END-----------------------------------------------------------Define audio input
BassAsio.BASS_ASIO_Start(0);
if (info.outputs > 0)
AsioOut[0].Start(0);
}
private bool NewRtpPacketLine1(RTPPacket packet, byte[] rawBuffer)
{
if (_decoder[0] != null)
{
byte[] pcm = _decoder[0].Decode(packet);
if (pcm != null)
{
Bass.BASS_StreamPutData(PushOut[0], pcm, pcm.Length);
if (BassAsio.BASS_ASIO_ChannelIsActive(false, 0) == BASSASIOActive.BASS_ASIO_ACTIVE_PAUSED)
{
BassAsio.BASS_ASIO_ChannelReset(false, 0, BASSASIOReset.BASS_ASIO_RESET_PAUSE);
}
//_asioOut[0].Start(0);
}
}
return false;
}
}
private int AsioInputCallbackCh0(bool input, int channel, IntPtr buffer, int length, IntPtr user)
{
if (length > 0)
{
byte[] ch0Bytes = new byte[length];
// the buffer member now contains the input sample data
if (_encoder[0] != null)
{
Bass.BASS_StreamPutData(PushIn[0], buffer, length);
Bass.BASS_ChannelGetData(PushIn[0], ch0Bytes, length);
RTPFrame frame = _encoder[0].EncodeToFrame(ch0Bytes);
if (frame != null) // && frame.PacketCount > 0)
{
if (_encoder[0] != null)
{
_session[0].Send(frame);
}
}
}
}
return 0;
}
}
}
}