0

I'm trying to use the bass.net library, but each time I try to create a stream from an audio file (mp3 and wav) I get a BASS_ERROR_FILE_OPEN error.

Actually, even the sample provided with bass.net lead to the same result.

Here is the code, which I assume is Ok since it comes from the sample :

        if ( Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero) )
        {
            // create a stream channel from a file
            int stream = Bass.BASS_StreamCreateFile("test.mp3", 0L, 0L, BASSFlag.BASS_DEFAULT);
            if (stream != 0)
            {
                // play the channel
                Bass.BASS_ChannelPlay(stream, false);
            }
            else
            {
                // error
                Console.WriteLine("Stream error: {0}", Bass.BASS_ErrorGetCode());
            }

            // wait for a key
            Console.WriteLine("Press any key to exit");
            Console.ReadKey(false);

            // free the stream
            Bass.BASS_StreamFree(stream);
            // free BASS
            Bass.BASS_Free();

The BASS_Init methods works correctly, the problem really comes from the StreamCreateFile.

The "test.mp3" file is correctly added to my project. I have a project reference to bass.net.dll and I also added the bass.dll file in bin/Debug, as said on bass website.

I can't figure out what I'm doing wrong, so I'll be grateful if anyone can help me.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Champy
  • 11
  • 4
  • Just to ensure the file is in the correct location in the bin, add the test.mp3 to your project (same level as program.cs) and on the test.mp3 files property in the explorer - set copy to output as "Copy if newer". It seems the library cant find the file – matt sharp Mar 22 '22 at 08:56
  • 1
    Oh indeed that worked ! Thanks a lot :) – Champy Mar 22 '22 at 09:24

0 Answers0