1 # -*- coding: utf-8 -*-
3 module de wrapping du synthétiseur
8 from os
.path
import realpath
, sep
, exists
9 from fluidsynth
import Synth
as FSynth
13 def __init__(self
, gain
=0.2, samplerate
=44100) :
14 FSynth
.__init
__(self
, gain
=gain
, samplerate
=samplerate
)
16 sfPath
= realpath(__file__
).split(sep
)
18 sfPath
.append('soundfonts')
20 sfPath
.append('FluidR3_GM.sf2')
21 sfPath
= sep
.join(sfPath
)
25 self
.fsid
= self
.sfload(sfPath
)
26 self
._octaveAjusts
= {}
28 def adjust_octave(self
, chan
, octave
) :
30 Abaisse ou élève les notes de n octave
32 self
._octaveAjusts
[chan
] = octave
34 def sfunload(self
, update_midi_preset
=0):
35 FSynth
.sfunload(self
, self
.fsid
, update_midi_preset
=update_midi_preset
)
37 def program_select(self
, chan
, bank
, preset
):
38 FSynth
.program_select(self
, chan
, self
.fsid
, bank
, preset
)
40 def sfont_select(self
, chan
):
41 FSynth
.sfont_select(self
, chan
, self
.fsid
)
43 def noteon(self
, chan
, key
, vel
):
44 key
= key
+ self
._octaveAjusts
.get(chan
, 0) * 12
45 FSynth
.noteon(self
, chan
, key
, vel
)
47 def noteoff(self
, chan
, key
) :
48 key
= key
+ self
._octaveAjusts
.get(chan
, 0) * 12
49 FSynth
.noteoff(self
, chan
, key
)
52 if __name__
== '__main__' :