0
0

Hi people.

I have my program written, but now i need a way to play MP3’s that are in my programs’ properties.resource file.
I have looked at the loadfrommemory sample program, and also searched this forum, but to no avail.

First.. the code i used:

first created the globals in the class:
[code:nsj8f0zi] private FMOD.System system = null;
private FMOD.Sound sound = null;
private FMOD.Channel channel = null;
private byte[] audiodata;[/code:nsj8f0zi]

that is all fine..
now in my form_load i do the following:
[code:nsj8f0zi] Currently = Playing.None; // Play Tune One

        //setup FMOD
        uint                   version = 0;
        FMOD.RESULT            result;
        //int                    length;
        //FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();

          /*
            Global Settings
        */
        result = FMOD.Factory.System_Create(ref system);
        ERRCHECK(result);

        result = system.getVersion(ref version);
        ERRCHECK(result);
        if (version < FMOD.VERSION.number)
        {
            MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
            Application.Exit();
        }

        result = system.init(1, FMOD.INITFLAG.NORMAL, (IntPtr)null);
        ERRCHECK(result);       

[/code:nsj8f0zi]

plus i have a routine that i use to change to the currect MP3 that i need:
[code:nsj8f0zi] private void ChangeMusic()
{
FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
FMOD.RESULT result;

        // load the new track
        switch(Currently)
        {
            case Playing.Tune1:
                exinfo.cbsize = Marshal.SizeOf(exinfo);
                exinfo.length = (uint) global::MusicDisk.Properties.Resources.Track1.Length;
                result =
                    system.createSound(global::MusicDisk.Properties.Resources.Track1,
                                       (FMOD.MODE.HARDWARE | FMOD.MODE.OPENMEMORY), ref exinfo, ref sound);
                ERRCHECK(result);
                result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
                ERRCHECK(result);

                break;

            case Playing.Tune2:
                break;

            case Playing.Tune3:
                break;

            case Playing.Tune4:
                break;

            case Playing.Tune5:
                break;
        }

    }

[/code:nsj8f0zi]

that all runs OK (i guess), unit the program hits this line:
[code:nsj8f0zi]result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);[/code:nsj8f0zi]
once this happens, it comes up with an out of memory/resources error!.
am i doing this the right way ? as i need to be able to play any track from the resource (names, Track1, Track2, Track3, Track4 and Track5).
Please help.

EDIT:
I did a little expirement, and replaced the large MP3’s (average size was 9mb, with small sub 300k mp3’s, and the sub 300k mp3’s seem to play fine !!.. it is just these large mp3’s that it doesn’t like. is there a maximum size of mp3 ? how do i fix this ?

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.