Hi, I wanted to say good job...
But I have one big issue which drives me crazy.
Decode channel and using BASS_ChannelGetData();
I use VS2019 and Win10.
EDIT: Now I have also tried with VS2022 and with Core. Same thing. Both using x86 and X64. Tried a dllimport of BASS_ChannelGetData and also the same thing. I don't understand.
Im trying both vb.net and C#.
The codes are exactly the same (converted though for C#) but it only works for vb.net and not C#.
In vb.net the buffer fills with data as it should but with C# it fills the buffer with only 0. The bytes read is the same for both and no errors.
I'm trying to open a mp3-file and read the data, filling it into a buffer, with a decoding channel. This is the code:
if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
{
MessageBox.Show("Couldn't init Bass" + Bass.BASS_ErrorGetCode());
return;
}
OpenFileDialog fdialog = new OpenFileDialog();
fdialog.Filter = "Music files (*.mp3, *.wav, *.flac)|*.mp3|*.wav|*.flac";
if (fdialog.ShowDialog() != DialogResult.OK) return;
string file = fdialog.FileName;
int stream = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_STREAM_PRESCAN);
if (stream == 0)
MessageBox.Show("Couldn't create stream: " + Bass.BASS_ErrorGetCode());
Bass.BASS_Free();
return;
}
long length = Bass.BASS_ChannelGetLength(stream, BASSMode.BASS_POS_BYTE);
if (length == -1)
MessageBox.Show("Couldn't get length: " + Bass.BASS_ErrorGetCode());
Bass.BASS_Free();
return;
}
short[] buffer = new short[length];
int readbytes = Bass.BASS_ChannelGetData(stream, buffer, (int)length);