Author Topic: Question on Changed soundfont during the MIDI played.  (Read 1945 times)

Gamo

  • Posts: 97
I got some problem about changing soundfont during played the MIDI file.
The sound is not smooth change. I use following code in VB to do that.
Code: [Select]
        If (NewSFont(EnPreset) And NewSFont(EnPreset) <> font1_) Then
            Dim sf1 As BASS_MIDI_FONT
            sf1.font = NewSFont(EnPreset)
            sf1.Preset = -1 ' use all presets
            sf1.bank = 0 ' use default bank(s)

            Call BASS_MIDI_StreamSetFonts(0, sf1, 1) ' set default soundfont
            Call BASS_MIDI_StreamSetFonts(chan1, sf1, 1) ' set for current stream too
           
            If BASS_ChannelIsActive(chan1) = BASS_ACTIVE_PLAYING Then
                 Call BASS_MIDI_StreamLoadSamples(chan1) [color=red]<== This line for reload the sample[/color]

            font1_ = NewSFont(EnPreset)

Any suggestion for this?

Thank you.

Ian @ un4seen

  • Administrator
  • Posts: 22250
By "smooth change", do you mean switching soundfonts without any break in sound? All notes are stopped when changing soundfonts, so I don't think it will be possible to totally avoid a break in sound, but you probably shouldn't call BASS_MIDI_StreamLoadSamples there, as that is likely to introduce an extra delay (while pre-loading the samples).

Gamo

  • Posts: 97
Ian,
After remove BASS_MIDI_StreamLoadSamples it work great.
There is few gap but acceptable.

Thank you.