@author: Samuel Benveniste\r
'''\r
from gui.constants import *\r
+import fluidsynth\r
\r
class Wiimote:\r
'''\r
cursor:\r
The cursor associated with the Wiimote \r
'''\r
- \r
self.number = number\r
self.portNumber = portNumber\r
self.port = port\r
self.cursor = cursor\r
self.numberPlayed = 0\r
\r
+ self.fs = fs = fluidsynth.Synth()\r
+ fs.start()\r
+ soundFont = r"C:\Documents and Settings\Administrator\My Documents\Telechargements\fluid-soundfont-3.1\FluidR3_GM.sf2"\r
+ self.fsid = fsid = fs.sfload(soundFont)\r
+ bank = 0\r
+ preset = 0\r
+ fs.program_select(0, fsid, bank, preset)\r
+\r
+ def __del__(self) :\r
+ self.fs.delete()\r
+ \r
def getNoteOnHexCode(self):\r
return (0x90 + self.instrument.channel - 1)\r
\r
def getCCHexCode(self):\r
return (0xB0 + self.instrument.channel - 1)\r
\r
- def playNote(self, note, velocity):\r
- noteNumber = self.instrument.getNote(note)\r
- \r
- if noteNumber != None :\r
- noteOnHexCode = self.getNoteOnHexCode()\r
- CCHexCode = self.getCCHexCode()\r
- else :\r
- noteNumber = defaultInstrumentNote\r
- noteOnHexCode = defaultNoteOnHexCode\r
- CCHexCode = defaultCCHexCode\r
- \r
- self.port.write_short(noteOnHexCode, noteNumber , 127)\r
- self.port.write_short(CCHexCode, 07, velocity)\r
+# def playNote(self, note, velocity):\r
+# print 'playNote'\r
+# noteNumber = self.instrument.getNote(note)\r
+# \r
+# if noteNumber != None :\r
+# noteOnHexCode = self.getNoteOnHexCode()\r
+# CCHexCode = self.getCCHexCode()\r
+# else :\r
+# noteNumber = defaultInstrumentNote\r
+# noteOnHexCode = defaultNoteOnHexCode\r
+# CCHexCode = defaultCCHexCode\r
+# \r
+# self.port.write_short(noteOnHexCode, noteNumber , 127)\r
+# self.port.write_short(CCHexCode, 07, velocity)\r
\r
def playNoteByNoteNumber(self, midiNoteNumber, velocity):\r
+ print 'playNoteByNumber'\r
+ noteNumber = self.instrument.getNoteByNoteNumber(midiNoteNumber)\r
+ fs = self.fs\r
+ fs.noteon(0, noteNumber, velocity)\r
+ \r
+ return\r
noteNumber = self.instrument.getNoteByNoteNumber(midiNoteNumber)\r
\r
if noteNumber != None :\r
\r
self.numberPlayed += 1\r
\r
- def stopNote(self, note):\r
- noteNumber = self.instrument.getNote(note)\r
- if noteNumber != None :\r
- noteOnHexCode = self.getNoteOnHexCode()\r
- else :\r
- noteNumber = defaultInstrumentNote\r
- noteOnHexCode = defaultNoteOnHexCode\r
- \r
- self.port.write_short(noteOnHexCode, noteNumber, 0)\r
+# def stopNote(self, note):\r
+# print 'stopNote'\r
+# noteNumber = self.instrument.getNote(note)\r
+# if noteNumber != None :\r
+# noteOnHexCode = self.getNoteOnHexCode()\r
+# else :\r
+# noteNumber = defaultInstrumentNote\r
+# noteOnHexCode = defaultNoteOnHexCode\r
+# \r
+# self.port.write_short(noteOnHexCode, noteNumber, 0)\r
\r
def stopNoteByNoteNumber(self, midiNoteNumber):\r
+ print 'stopNoteByNoteNumber'\r
+ \r
+ noteNumber = self.instrument.getNoteByNoteNumber(midiNoteNumber)\r
+ fs = self.fs\r
+ fs.noteoff(0, noteNumber)\r
+ \r
+ return\r
noteNumber = self.instrument.getNoteByNoteNumber(midiNoteNumber)\r
if noteNumber != None :\r
noteOnHexCode = self.getNoteOnHexCode()\r
\r
self.port.write_short(noteOnHexCode, noteNumber, 0)\r
\r
- def allNotesOff(self):\r
- CCHexCode = self.getCCHexCode()\r
- self.port.write_short(CCHexCode,123,0)
\ No newline at end of file
+# def allNotesOff(self):\r
+# print 'allNoteOff'\r
+# CCHexCode = self.getCCHexCode()\r
+# self.port.write_short(CCHexCode,123,0)\r