0
0

It seems like this forum has been abandoned! :(

I’m trying to get an MP3 playing using a stream created by FSOUND_Stream_Create. All I’m getting is static so I’m guessing I’m doing something very basic wrong.

Can someone take a look at the following code, and tell me where I’m going wrong? It’s in C#, using a FMOD wrapper, but that shouldn’t make a difference – it’s still the familiar FMOD functions.

[code:16lv708b] static void Main(string[] args)
{
uint mode = FMOD.FSOUND_NORMAL | FMOD.FSOUND_16BITS | FMOD.FSOUND_STEREO;
bool initOkay = FMOD.FSOUND_Init(44100, 32, 0);
IntPtr stream = FMOD.FSOUND_Stream_Create(StreamCallback, 48000, mode, 24000, IntPtr.Zero);

        sourceStream = new FileStream("Kalimba.mp3", FileMode.Open, FileAccess.Read);

        int playResult = FMOD.FSOUND_Stream_Play(FMOD.FSOUND_FREE, stream);

        Console.ReadLine();
    }

    static IntPtr StreamCallback(IntPtr stream, IntPtr buffer, int length, IntPtr userdata)
    {
        byte[] readBuffer = new byte[length];

        int bytesRead = sourceStream.Read(readBuffer, 0, length);
        Marshal.Copy(readBuffer, 0, buffer, bytesRead);

        return new IntPtr(1);
    }

[/code:16lv708b]

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.