Ejemplo n.º 1
0
        public static int LoadMidiMusic(MidiEvent[] events, int pulsesPerQuarterNode, uint frequency)
        {
            if (soundFont == 0)
            {
                var assembly = Assembly.GetExecutingAssembly();
                var stream   = assembly.GetManifestResourceStream(SoundFontResource); // Don't dispose it!
                soundFontProcs = SoundFontStream.CreateSoundFontFileProcs(stream);
                soundFont      = NativeBass.BASS_MIDI_FontInitUser(soundFontProcs, IntPtr.Zero, 0u);
            }

            const DWORD loop  = 0x04u;
            int         music = NativeBass.BASS_MIDI_StreamCreateEvents(events, (DWORD)pulsesPerQuarterNode, loop, frequency);

            var fonts = new NativeBass.MidiFont[]
            {
                new NativeBass.MidiFont()
                {
                    Font   = soundFont,
                    Preset = -1,
                    Bank   = 0
                }
            };

            NativeBass.BASS_MIDI_StreamSetFonts(music, fonts, 1u);

            return(music);
        }
Ejemplo n.º 2
0
            public unsafe static NativeBass.SoundFontFileProcs CreateSoundFontFileProcs(Stream stream)
            {
                var soundFontStream = new SoundFontStream(stream);

                return(new NativeBass.SoundFontFileProcs()
                {
                    Close = new NativeBass.SoundFontCloseProcedure(soundFontStream.Close),
                    Length = new NativeBass.SoundFontLengthProcedure(soundFontStream.Length),
                    Read = new NativeBass.SoundFontReadProcedure(soundFontStream.Read),
                    Seek = new NativeBass.SoundFontSeekProcedure(soundFontStream.Seek)
                });
            }