public iSoundSourceObject LoadSound(string filename) { String extension = Path.GetExtension(filename); if (extension.Equals(".xm", StringComparison.OrdinalIgnoreCase)) { Debug.Print("xm file..."); } int stmake = 0; if (new String[] { ".xm", ".it",".mod" }.Contains(extension.ToLower())) { stmake = Bass.BASS_MusicLoad(filename, 0, 0, BASSFlag.BASS_DEFAULT, 0); } else { stmake = Bass.BASS_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_DEFAULT); } if (stmake != 0) { BASSSound returnsound = new BASSSound(stmake); returnsound.BASS_SoundStopped+=BasssoundStop; return returnsound; } return null; }
private void BasssoundStop(BASSSound soundstopped) { FireSoundStop(soundstopped); }
public iSoundSourceObject LoadSound(byte[] data, string sName, string fileextension) { String extension = fileextension; if (extension.Equals(".xm", StringComparison.OrdinalIgnoreCase)) { Debug.Print("xm file..."); } int stmake = 0; //we need to allocate some unmanaged memory. IntPtr unmanagedPointer = Marshal.AllocHGlobal(data.Length); Marshal.Copy(data, 0, unmanagedPointer, data.Length); if (new String[] {".xm", ".it"}.Contains(extension.ToLower())) { stmake = Bass.BASS_MusicLoad(unmanagedPointer , 0, 0, BASSFlag.BASS_DEFAULT, 0); } else { stmake = Bass.BASS_StreamCreateFile(unmanagedPointer, 0, 0, BASSFlag.BASS_DEFAULT); } if (stmake != 0) { //create the BASSSound object; we need to give it the unManagedPointer, so that it will be able to properly free that resource when it is destructed. BASSSound returnsound = new BASSSound(stmake,unmanagedPointer); returnsound.BASS_SoundStopped += BasssoundStop; return returnsound; } return null; }