Midi file

Hi Marc,
I really enjoy working with Scamp. I recently tried to export to midi file which works fine … except that I only get Piano tracks. The sf2 instruments are not attached to the export … I tried to check implementation of FluidSynth but it seems OK … any idea ?
Thanks
Marc

Oh, yeah, I’ll have to check on that; I’m not sure that midi instrument information is being exported.

Hi Marc,
Just in case it maybe useful for others, I managed to add instruments in the midi files by using miditookit with the code below. This allows me to generate the wav file with midi2audio from the midi file.
All the best,
Marc

    import miditoolkit
    i=0
    presets=[]
    # need to check that parts contained some notes to play (tracks are not generated if no  sound)     
    for tr in performance.parts:
        notempty=False
        for imp in tr.instrument.playback_implementations:
            for sq in ph.parts[i]:
                for p in sq.pitcharray:
                    if p>0:
                        notempty=True
                        break
            if notempty:
                presets.append(imp.bank_and_preset)
        i+=1
    print(presets)
    midi_obj = miditoolkit.MidiFile(self.path_sound_data+'test.mid')
    
    for track, ps in zip(midi_obj.instruments, presets):

        track.program=ps[1]
        if ps[0]>0:
           track.program=ps[1]
           track.is_drum=True
        else:
           track.program=ps[1]
1 Like