Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Player
diff options
context:
space:
mode:
Diffstat (limited to 'Player')
-rw-r--r--Player/GenRythm.py38
-rw-r--r--Player/KeyboardStandAlone.py17
-rw-r--r--Player/NoteStdAlone.py35
-rw-r--r--Player/RythmGenerator.py15
-rw-r--r--Player/RythmPlayer.py9
-rw-r--r--Player/StandalonePlayer.py427
-rw-r--r--Player/StandalonePlayerOld.py4
7 files changed, 486 insertions, 59 deletions
diff --git a/Player/GenRythm.py b/Player/GenRythm.py
index c607d07..0cba969 100644
--- a/Player/GenRythm.py
+++ b/Player/GenRythm.py
@@ -1,8 +1,8 @@
import random
-from Framework.Generation.GenerationConstants import GenerationConstants
-from Framework.CSound.CSoundConstants import CSoundConstants
-from Framework.Constants import Constants
-from Framework.Generation.Utils import *
+import Config
+
+from Generation.GenerationConstants import GenerationConstants
+from Generation.Utils import *
class GenRythm:
def __init__( self, instrument, barLength, nbeats ):
@@ -20,49 +20,49 @@ class GenRythm:
density = 0.8
countDown = 0
onsetTime = None
- beatsPerPage = int( self.barLength / Constants.TICKS_PER_BEAT )
+ beatsPerPage = int( self.barLength / Config.TICKS_PER_BEAT )
- if CSoundConstants.INSTRUMENTS[ self.instrument ].instrumentRegister == CSoundConstants.PUNCH:
+ if Config.INSTRUMENTS[ self.instrument ].instrumentRegister == Config.PUNCH:
registerDensity = 0.5
downBeatRecurence = 4
for beat in range( beatsPerPage ):
- beats.append( beat * Constants.TICKS_PER_BEAT )
+ beats.append( beat * Config.TICKS_PER_BEAT )
for i in range( len( beats ) ):
downBeats.append( ( beats[ GenerationConstants.PUNCH_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) )
for downBeat in downBeats:
- upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT , downBeat[ 1 ] ) )
+ upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT , downBeat[ 1 ] ) )
- if CSoundConstants.INSTRUMENTS[ self.instrument ].instrumentRegister == CSoundConstants.LOW:
+ if Config.INSTRUMENTS[ self.instrument ].instrumentRegister == Config.LOW:
registerDensity =1.5
downBeatRecurence = 4
for beat in range( beatsPerPage ):
- beats.append( beat * Constants.TICKS_PER_BEAT )
+ beats.append( beat * Config.TICKS_PER_BEAT )
for i in range( len( beats ) ):
downBeats.append( ( beats[ GenerationConstants.LOW_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) )
for downBeat in downBeats:
- upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 2 , downBeat[ 1 ] ) )
+ upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 2 , downBeat[ 1 ] ) )
- if CSoundConstants.INSTRUMENTS[ self.instrument ].instrumentRegister == CSoundConstants.MID:
+ if Config.INSTRUMENTS[ self.instrument ].instrumentRegister == Config.MID:
registerDensity = .75
downBeatRecurence = 1
for beat in range( beatsPerPage ):
- beats.append( beat * Constants.TICKS_PER_BEAT )
- beats.append( beat * Constants.TICKS_PER_BEAT + ( Constants.TICKS_PER_BEAT / 2 ) )
+ beats.append( beat * Config.TICKS_PER_BEAT )
+ beats.append( beat * Config.TICKS_PER_BEAT + ( Config.TICKS_PER_BEAT / 2 ) )
for i in range( len( beats ) ):
downBeats.append( ( beats[ GenerationConstants.MID_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) )
for downBeat in downBeats:
- upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) )
+ upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) )
- if CSoundConstants.INSTRUMENTS[ self.instrument ].instrumentRegister == CSoundConstants.HIGH:
+ if Config.INSTRUMENTS[ self.instrument ].instrumentRegister == Config.HIGH:
registerDensity = 1.5
downBeatRecurence = 1
for beat in range( beatsPerPage ):
- beats.append( beat * Constants.TICKS_PER_BEAT )
- beats.append( beat * Constants.TICKS_PER_BEAT + ( Constants.TICKS_PER_BEAT / 2 ) )
+ beats.append( beat * Config.TICKS_PER_BEAT )
+ beats.append( beat * Config.TICKS_PER_BEAT + ( Config.TICKS_PER_BEAT / 2 ) )
for i in range( len( beats ) ):
downBeats.append( ( beats[ GenerationConstants.HIGH_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) )
for downBeat in downBeats:
- upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) )
+ upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) )
for i in range( int( density * registerDensity * len( downBeats ) ) ):
if random.randint( 0, 100 ) < ( regularity * 100 * downBeatRecurence ) and binSelection.count( 1 ) < len( downBeats ):
diff --git a/Player/KeyboardStandAlone.py b/Player/KeyboardStandAlone.py
index 7b41c1b..4c64317 100644
--- a/Player/KeyboardStandAlone.py
+++ b/Player/KeyboardStandAlone.py
@@ -2,11 +2,12 @@ import pygtk
pygtk.require( '2.0' )
import gtk
+import Config
+#TODO: this is a suprising dependency... what's up??
+from Generation.GenerationConstants import GenerationConstants
from Player.NoteStdAlone import NoteStdAlone
-from Framework.CSound.CSoundConstants import CSoundConstants
-from Framework.Generation.GenerationConstants import GenerationConstants
-from GUI.Core.KeyMapping import KEY_MAP_PIANO
+KEY_MAP_PIANO = Config.KEY_MAP_PIANO
class KeyboardStandAlone:
def __init__( self, client, recordingFunction, adjustDurationFunction, getCurrentTick ):
@@ -47,16 +48,16 @@ class KeyboardStandAlone:
pitch = GenerationConstants.DRUMPITCH[ pitch ]
if instrument == 'drum1kit':
- instrument = CSoundConstants.DRUM1INSTRUMENTS[ pitch ]
+ instrument = Config.DRUM1INSTRUMENTS[ pitch ]
if instrument == 'drum2kit':
- instrument = CSoundConstants.DRUM2INSTRUMENTS[ pitch ]
+ instrument = Config.DRUM2INSTRUMENTS[ pitch ]
if instrument == 'drum3kit':
- instrument = CSoundConstants.DRUM3INSTRUMENTS[ pitch ]
+ instrument = Config.DRUM3INSTRUMENTS[ pitch ]
pitch = 36
duration = 100
- if CSoundConstants.INSTRUMENTS[instrument].csoundInstrumentID == CSoundConstants.INST_PERC: #Percussions resonance
+ if Config.INSTRUMENTS[instrument].csoundInstrumentID == Config.INST_PERC: #Percussions resonance
duration = 60
# Create and play the note
self.key_dict[key] = NoteStdAlone(client = self.csnd,
@@ -89,7 +90,7 @@ class KeyboardStandAlone:
key = event.hardware_keycode
if KEY_MAP_PIANO.has_key(key):
- if CSoundConstants.INSTRUMENTS[ self.key_dict[key].instrument].csoundInstrumentID == CSoundConstants.INST_TIED:
+ if Config.INSTRUMENTS[ self.key_dict[key].instrument].csoundInstrumentID == Config.INST_TIED:
self.key_dict[key].duration = 1
self.key_dict[key].decay = 0.88
self.key_dict[key].amplitude = 1
diff --git a/Player/NoteStdAlone.py b/Player/NoteStdAlone.py
index 9722899..a64bd64 100644
--- a/Player/NoteStdAlone.py
+++ b/Player/NoteStdAlone.py
@@ -1,7 +1,6 @@
-from Framework.Constants import Constants
-from Framework.CSound.CSoundClient import CSoundClient
-from Framework.CSound.CSoundConstants import CSoundConstants
-from Framework.Generation.GenerationConstants import GenerationConstants
+import Config
+from Util.CSoundClient import CSoundClient
+from Generation.GenerationConstants import GenerationConstants
class NoteStdAlone:
def __init__( self, client,
@@ -12,7 +11,7 @@ class NoteStdAlone:
duration,
trackID,
fullDuration = False,
- instrument = CSoundConstants.FLUTE,
+ instrument = Config.FLUTE,
attack = 0.005,
decay = 0.095,
reverbSend = 0.1,
@@ -20,7 +19,7 @@ class NoteStdAlone:
filterCutoff = 1000,
tied = False,
overlap = False,
- instrumentFlag = CSoundConstants.FLUTE ):
+ instrumentFlag = Config.FLUTE ):
self.csnd = client
self.onset = onset
self.pitch = pitch
@@ -38,7 +37,7 @@ class NoteStdAlone:
self.tied = tied
self.overlap = overlap
if self.instrument == 'drum1kit':
- self.instrumentFlag = CSoundConstants.DRUM1INSTRUMENTS[ self.pitch ]
+ self.instrumentFlag = Config.DRUM1INSTRUMENTS[ self.pitch ]
else:
self.instrumentFlag = self.instrument
@@ -51,25 +50,25 @@ class NoteStdAlone:
self.pitch = GenerationConstants.DRUMPITCH[ self.pitch ]
if self.instrument == 'drum1kit':
- self.instrumentFlag = CSoundConstants.DRUM1INSTRUMENTS[ self.pitch ]
+ self.instrumentFlag = Config.DRUM1INSTRUMENTS[ self.pitch ]
if self.instrument == 'drum2kit':
- self.instrumentFlag = CSoundConstants.DRUM2INSTRUMENTS[ self.pitch ]
+ self.instrumentFlag = Config.DRUM2INSTRUMENTS[ self.pitch ]
if self.instrument == 'drum3kit':
- self.instrumentFlag = CSoundConstants.DRUM3INSTRUMENTS[ self.pitch ]
+ self.instrumentFlag = Config.DRUM3INSTRUMENTS[ self.pitch ]
newPitch = 1
else:
self.instrumentFlag = self.instrument
newPitch = pow( GenerationConstants.TWO_ROOT_TWELVE, self.pitch - 36 )
- oneTickDuration = (Constants.MS_PER_MINUTE / 1000) / tempo / Constants.TICKS_PER_BEAT
+ oneTickDuration = (Config.MS_PER_MINUTE / 1000) / tempo / Config.TICKS_PER_BEAT
newDuration = oneTickDuration * self.duration
# condition for tied notes
- if CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 101 and self.tied and self.fullDuration:
+ if Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 101 and self.tied and self.fullDuration:
newDuration = -1
# condition for overlaped notes
- if CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 102 and self.overlap:
+ if Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 102 and self.overlap:
newDuration = oneTickDuration * self.duration + 1.
if True: newAmplitude = self.amplitude * 0.8
@@ -83,10 +82,10 @@ class NoteStdAlone:
if newDecay <= 0.002:
newDecay = 0.002
- loopStart = CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].loopStart
- loopEnd = CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].loopEnd
- crossDur = CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].crossDur
- return CSoundConstants.PLAY_NOTE_COMMAND % ( CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID,
+ loopStart = Config.INSTRUMENTS[ self.instrumentFlag ].loopStart
+ loopEnd = Config.INSTRUMENTS[ self.instrumentFlag ].loopEnd
+ crossDur = Config.INSTRUMENTS[ self.instrumentFlag ].crossDur
+ return Config.PLAY_NOTE_COMMAND % ( Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID,
self.trackID,
0,
newDuration,
@@ -94,7 +93,7 @@ class NoteStdAlone:
self.reverbSend,
newAmplitude,
self.pan,
- CSoundConstants.INSTRUMENT_TABLE_OFFSET + CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].instrumentID,
+ Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ self.instrumentFlag ].instrumentID,
newAttack,
newDecay,
self.filterType,
diff --git a/Player/RythmGenerator.py b/Player/RythmGenerator.py
index e92e081..4e141ec 100644
--- a/Player/RythmGenerator.py
+++ b/Player/RythmGenerator.py
@@ -1,10 +1,9 @@
import random
import math
-from Framework.Constants import Constants
-from Framework.CSound.CSoundConstants import CSoundConstants
+import Config
from Player.NoteStdAlone import NoteStdAlone
-from Framework.Generation.GenerationConstants import GenerationConstants
+from Generation.GenerationConstants import GenerationConstants
from Player.GenRythm import GenRythm
def generator( instrument, nbeats, regularity, reverbSend, client ):
@@ -20,7 +19,7 @@ def generator( instrument, nbeats, regularity, reverbSend, client ):
for onset in onsetList:
if onset == 0:
gain = random.uniform(GenerationConstants.GAIN_MID_MAX_BOUNDARY, GenerationConstants.GAIN_MAX_BOUNDARY)
- elif ( onset % Constants.TICKS_PER_BEAT) == 0:
+ elif ( onset % Config.TICKS_PER_BEAT) == 0:
gain = random.uniform(GenerationConstants.GAIN_MID_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MAX_BOUNDARY)
else:
gain = random.uniform(GenerationConstants.GAIN_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MIN_BOUNDARY)
@@ -41,13 +40,13 @@ def generator( instrument, nbeats, regularity, reverbSend, client ):
return durationSequence, fullDurationSequence
def pageGenerate( regularity, drumPitch ):
- barLength = Constants.TICKS_PER_BEAT * nbeats
+ barLength = Config.TICKS_PER_BEAT * nbeats
if instrument == 'drum1kit':
- currentInstrument = CSoundConstants.DRUM1INSTRUMENTS[ drumPitch[ 0 ] ]
+ currentInstrument = Config.DRUM1INSTRUMENTS[ drumPitch[ 0 ] ]
elif instrument == 'drum2kit':
- currentInstrument = CSoundConstants.DRUM2INSTRUMENTS[ drumPitch[ 0 ] ]
+ currentInstrument = Config.DRUM2INSTRUMENTS[ drumPitch[ 0 ] ]
elif instrument == 'drum3kit':
- currentInstrument = CSoundConstants.DRUM3INSTRUMENTS[ drumPitch[ 0 ] ]
+ currentInstrument = Config.DRUM3INSTRUMENTS[ drumPitch[ 0 ] ]
makeRythm = GenRythm( currentInstrument, barLength, nbeats )
diff --git a/Player/RythmPlayer.py b/Player/RythmPlayer.py
index ba0b11a..cfd54b7 100644
--- a/Player/RythmPlayer.py
+++ b/Player/RythmPlayer.py
@@ -3,10 +3,9 @@ pygtk.require( '2.0' )
import gtk
import gobject
-from Framework.Constants import Constants
-from Framework.CSound.CSoundNote import CSoundNote
-from Framework.CSound.CSoundClient import CSoundClient
-from Framework.CSound.CSoundConstants import CSoundConstants
+import Config
+from Util.CSoundNote import CSoundNote
+from Util.CSoundClient import CSoundClient
class RythmPlayer:
def __init__( self, client, recordButtonState ):
@@ -98,7 +97,7 @@ class RythmPlayer:
self.startLooking = 0
self.currentTick = self.currentTick + 1
- if self.currentTick >= (Constants.TICKS_PER_BEAT * self.beat):
+ if self.currentTick >= (Config.TICKS_PER_BEAT * self.beat):
if self.recordState:
self.recordState = 0
self.sequencerPlayback = 1
diff --git a/Player/StandalonePlayer.py b/Player/StandalonePlayer.py
new file mode 100644
index 0000000..77b1aa3
--- /dev/null
+++ b/Player/StandalonePlayer.py
@@ -0,0 +1,427 @@
+import pygtk
+pygtk.require( '2.0' )
+import gtk
+import os
+import random
+
+import Config
+
+from Util.ThemeWidgets import *
+from Util.Credits import Credits
+
+from Player.KeyboardStandAlone import KeyboardStandAlone
+from Player.NoteStdAlone import NoteStdAlone
+from Player.RythmPlayer import RythmPlayer
+from Player.RythmGenerator import *
+from SynthLab.SynthLabWindow import SynthLabWindow
+
+Tooltips = Config.Tooltips
+
+class StandAlonePlayer( gtk.EventBox ):
+
+ def __init__(self, client):
+ gtk.EventBox.__init__( self)
+ self.set_border_width(Config.MAIN_WINDOW_PADDING)
+
+ self.csnd = client
+
+ self.instrument = self.getInstrumentList()[0]
+ self.reverb = 0.
+ self.volume = 80
+ self.regularity = 0.75
+ self.beat = 4
+ self.tempo = 130
+ self.rythmPlayer = RythmPlayer(self.csnd, self.recordStateButton)
+ self.rythmInstrument = 'drum1kit'
+
+ self.synthLabWindow1 = SynthLabWindow(self.csnd, 86)
+ self.synthLabWindow2 = SynthLabWindow(self.csnd, 87)
+ self.synthLabWindow3 = SynthLabWindow(self.csnd, 88)
+ self.synthLabWindow4 = SynthLabWindow(self.csnd, 89)
+
+ self.csnd.setMasterVolume(self.volume)
+ self.rythmPlayer.beat = self.beat
+ self.rythmPlayer.notesList = generator( self.rythmInstrument, self.beat, self.regularity, self.reverb, self.csnd)
+
+ self.tooltips = gtk.Tooltips()
+
+ self.creditsOpen = False
+ self.recstate = False
+
+ self.mainWindowBox = gtk.HBox()
+ self.leftBox = gtk.VBox()
+ self.rightBox = gtk.VBox()
+ self.mainWindowBox.add(self.leftBox)
+ self.mainWindowBox.add(self.rightBox)
+ self.add(self.mainWindowBox)
+
+ self.enableKeyboard()
+ self.setInstrument(self.instrument)
+
+ self.drawInstrumentButtons()
+ self.drawMicBox()
+ self.drawSliders()
+ #self.drawLogo()
+ self.drawGeneration()
+ self.show_all()
+ self.playStartupSound()
+
+ def drawLogo(self):
+ eventbox = gtk.EventBox()
+ eventbox.connect('button-press-event', self.handleLogoPress)
+ logo = gtk.Image()
+ logo.set_from_file(Config.IMAGE_ROOT + 'tamtam_rouge.png')
+ eventbox.add(logo)
+ self.middleBox.add(eventbox)
+
+ def handleLogoPress(self, widget, event):
+ pos = widget.window.get_origin()
+ if self.creditsOpen is False:
+ credits = Credits(self.handleCreditsClose , pos)
+ self.handleCreditsClose(True)
+
+ def handleCreditsClose(self , state):
+ self.creditsOpen = state
+
+ def drawSliders( self ):
+ mainSliderBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
+ mainSliderBox.set_border_width(Config.BORDER_SIZE)
+
+ reverbSliderBox = gtk.HBox()
+ self.reverbSliderBoxImgTop = gtk.Image()
+ self.reverbSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'reverb0.png')
+ reverbAdjustment = gtk.Adjustment(value=self.reverb, lower=0, upper=1, step_incr=0.1, page_incr=0, page_size=0)
+ reverbSlider = ImageHScale( Config.IMAGE_ROOT + "sliderbutred.png", reverbAdjustment, 7 )
+ reverbSlider.set_inverted(False)
+ reverbSlider.set_size_request(350,15)
+ reverbAdjustment.connect("value_changed" , self.handleReverbSlider)
+ reverbSliderBox.pack_start(reverbSlider, True, 20)
+ reverbSliderBox.pack_start(self.reverbSliderBoxImgTop, False, padding=0)
+ self.tooltips.set_tip(reverbSlider,Tooltips.REV)
+
+ volumeSliderBox = gtk.HBox()
+ self.volumeSliderBoxImgTop = gtk.Image()
+ self.volumeSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'volume2.png')
+ volumeAdjustment = gtk.Adjustment(value=self.volume, lower=0, upper=100, step_incr=1, page_incr=0, page_size=0)
+ volumeSlider = ImageHScale( Config.IMAGE_ROOT + "sliderbutviolet.png", volumeAdjustment, 7 )
+ volumeSlider.set_inverted(False)
+ volumeSlider.set_size_request(350,15)
+ volumeAdjustment.connect("value_changed" , self.handleVolumeSlider)
+ volumeSliderBox.pack_start(volumeSlider, True, 20)
+ volumeSliderBox.pack_start(self.volumeSliderBoxImgTop, False, padding=0)
+ self.tooltips.set_tip(volumeSlider,Tooltips.VOL)
+
+ mainSliderBox.pack_start(volumeSliderBox, True, True, 5)
+ mainSliderBox.pack_start(reverbSliderBox, True, True, 5)
+
+ self.leftBox.add(mainSliderBox)
+
+ def drawGeneration( self ):
+
+ slidersBox = RoundVBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
+ slidersBox.set_border_width(Config.BORDER_SIZE)
+ geneButtonBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
+ geneButtonBox.set_border_width(Config.BORDER_SIZE)
+ transportBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
+ transportBox.set_border_width(Config.BORDER_SIZE)
+
+ geneSliderBox = gtk.VBox()
+ self.geneSliderBoxImgTop = gtk.Image()
+ self.geneSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'complex6.png')
+ geneAdjustment = gtk.Adjustment(value=self.regularity, lower=0, upper=1, step_incr=0.01, page_incr=0, page_size=0)
+ geneSlider = ImageVScale( Config.IMAGE_ROOT + "sliderbutbleu.png", geneAdjustment, 5 )
+ geneSlider.set_inverted(False)
+ geneSlider.set_size_request(15,408)
+ geneAdjustment.connect("value_changed" , self.handleGenerationSlider)
+ geneSlider.connect("button-release-event", self.handleGenerationSliderRelease)
+ geneSliderBox.pack_start(self.geneSliderBoxImgTop, False, padding=10)
+ geneSliderBox.pack_start(geneSlider, True, 20)
+ self.tooltips.set_tip(geneSlider,Tooltips.COMPL)
+
+ beatSliderBox = gtk.VBox()
+ self.beatSliderBoxImgTop = gtk.Image()
+ self.beatSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'beat3.png')
+ beatAdjustment = gtk.Adjustment(value=self.beat, lower=2, upper=12, step_incr=1, page_incr=0, page_size=0)
+ beatSlider = ImageVScale( Config.IMAGE_ROOT + "sliderbutjaune.png", beatAdjustment, 5, snap = 1 )
+ beatSlider.set_inverted(True)
+ beatSlider.set_size_request(15,408)
+ beatAdjustment.connect("value_changed" , self.handleBeatSlider)
+ beatSlider.connect("button-release-event", self.handleBeatSliderRelease)
+ beatSliderBox.pack_start(self.beatSliderBoxImgTop, False, padding=10)
+ beatSliderBox.pack_start(beatSlider, True, 20)
+ self.tooltips.set_tip(beatSlider,Tooltips.BEAT)
+
+ tempoSliderBox = gtk.VBox()
+ self.tempoSliderBoxImgTop = gtk.Image()
+ self.tempoSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'tempo5.png')
+ tempoAdjustment = gtk.Adjustment(value=self.tempo, lower=40, upper=240, step_incr=1, page_incr=1, page_size=1)
+ tempoSlider = ImageVScale( Config.IMAGE_ROOT + "sliderbutvert.png", tempoAdjustment, 5)
+ tempoSlider.set_inverted(True)
+ tempoSlider.set_size_request(15,408)
+ tempoAdjustment.connect("value_changed" , self.setTempo)
+ tempoSliderBox.pack_start(self.tempoSliderBoxImgTop, False, padding=10)
+ tempoSliderBox.pack_start(tempoSlider, True)
+ self.tooltips.set_tip(tempoSlider,Tooltips.TEMPO)
+
+ slidersBoxSub = gtk.HBox()
+ slidersBoxSub.pack_start(geneSliderBox)
+ slidersBoxSub.pack_start(beatSliderBox)
+ slidersBoxSub.pack_start(tempoSliderBox)
+ slidersBox.pack_start(slidersBoxSub)
+
+ generateBtn = ImageButton(Config.IMAGE_ROOT + 'dice.png', click_image_path = Config.IMAGE_ROOT + 'diceblur.png')
+ generateBtn.connect('clicked', self.handleGenerateBtn)
+ slidersBox.pack_start(generateBtn)
+ self.tooltips.set_tip(generateBtn,Tooltips.GEN)
+
+ #Generation Button Box
+ geneSubBox = gtk.VBox()
+ geneSubBoxTop = gtk.HBox()
+
+ generationDrumBtn1 = ImageRadioButton(group = None , mainImg_path = Config.IMAGE_ROOT + 'drum1kit.png' , altImg_path = Config.IMAGE_ROOT + 'drum1kitselgen.png')
+ generationDrumBtn1.connect('clicked' , self.handleGenerationDrumBtn , 'drum1kit')
+ geneSubBoxTop.pack_start(generationDrumBtn1)
+ generationDrumBtn2 = ImageRadioButton(group = generationDrumBtn1 , mainImg_path = Config.IMAGE_ROOT + 'drum2kit.png' , altImg_path = Config.IMAGE_ROOT + 'drum2kitselgen.png')
+ generationDrumBtn2.connect('clicked' , self.handleGenerationDrumBtn , 'drum2kit')
+ geneSubBoxTop.pack_start(generationDrumBtn2)
+ generationDrumBtn3 = ImageRadioButton(group = generationDrumBtn1 , mainImg_path = Config.IMAGE_ROOT + 'drum3kit.png' , altImg_path = Config.IMAGE_ROOT + 'drum3kitselgen.png')
+ generationDrumBtn3.connect('clicked' , self.handleGenerationDrumBtn , 'drum3kit')
+ geneSubBox.pack_start(geneSubBoxTop, True)
+ geneSubBox.pack_start(generationDrumBtn3, True)
+ geneButtonBox.pack_start(geneSubBox, True)
+ self.tooltips.set_tip(generationDrumBtn1,Tooltips.JAZZ)
+ self.tooltips.set_tip(generationDrumBtn2,Tooltips.ARAB)
+ self.tooltips.set_tip(generationDrumBtn3,Tooltips.AFRI)
+
+ #Transport Button Box
+ self.seqRecordButton = ImageToggleButton(Config.IMAGE_ROOT + 'record2.png', Config.IMAGE_ROOT + 'record2sel.png')
+ self.seqRecordButton.connect('clicked', self.rythmPlayer.handleRecordButton )
+
+ self.playStopButton = ImageToggleButton(Config.IMAGE_ROOT + 'play.png', Config.IMAGE_ROOT + 'stop.png')
+ self.playStopButton.connect('clicked' , self.handlePlayButton)
+ transportBox.pack_start(self.seqRecordButton)
+ transportBox.pack_start(self.playStopButton)
+ self.tooltips.set_tip(self.seqRecordButton,Tooltips.SEQ)
+ self.tooltips.set_tip(self.playStopButton,Tooltips.PLAY)
+
+ self.rightBox.pack_start(slidersBox, True)
+ self.rightBox.pack_start(geneButtonBox, True)
+ self.rightBox.pack_start(transportBox, True)
+
+
+ def drawInstrumentButtons(self):
+ ROW_LEN = 8
+
+ vBox = gtk.VBox()
+
+ intrumentNum = len(self.getInstrumentList())
+ rows = ( intrumentNum // ROW_LEN )
+ if intrumentNum % ROW_LEN is not 0: #S'il y a un reste
+ rows = rows + 1
+
+ self.firstInstButton = None
+ for row in range(rows):
+ hBox = gtk.HBox()
+ for instrument in self.getInstrumentList()[row*ROW_LEN:(row+1)*ROW_LEN]:
+ instBox = RoundVBox(fillcolor = Config.INST_BCK_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
+ instBox.set_border_width(Config.BORDER_SIZE)
+ instButton = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + instrument + '.png' , Config.IMAGE_ROOT + instrument + 'sel.png', Config.IMAGE_ROOT + instrument + 'sel.png')
+ if self.firstInstButton == None:
+ self.firstInstButton = instButton
+ instButton.connect('clicked' , self.handleInstrumentButtonClick , instrument)
+ instBox.add(instButton)
+ hBox.add(instBox)
+ vBox.add(hBox)
+ self.leftBox.add(vBox)
+
+ def drawMicBox( self ):
+ hbox = gtk.HBox()
+
+ for n in ['mic1','mic2','mic3','mic4']:
+ vbox1 = RoundVBox(fillcolor = Config.INST_BCK_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
+ vbox1.set_border_width(Config.BORDER_SIZE)
+
+ micBtn = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + n + '.png' , Config.IMAGE_ROOT + n + 'sel.png', Config.IMAGE_ROOT + n + 'sel.png')
+ micRecBtn = ImageButton(Config.IMAGE_ROOT + 'record.png' , Config.IMAGE_ROOT + 'recordhi.png', Config.IMAGE_ROOT + 'recordsel.png')
+ self.tooltips.set_tip(micRecBtn,Tooltips.RECMIC)
+
+ micBtn.connect('clicked', self.handleInstrumentButtonClick, n)
+ micRecBtn.connect('clicked', self.handleMicButtonClick, n)
+ micRecBtn.connect('pressed', self.handleRecButtonPress, micBtn)
+
+ vbox1.add(micRecBtn)
+ vbox1.add(micBtn)
+ hbox.add(vbox1)
+
+ for n in ['lab1','lab2','lab3','lab4']:
+ vbox2 = RoundVBox(fillcolor = Config.INST_BCK_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
+ vbox2.set_border_width(Config.BORDER_SIZE)
+
+ synthBtn = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + n + '.png', Config.IMAGE_ROOT + n + 'sel.png', Config.IMAGE_ROOT + n + 'sel.png')
+ synthRecBtn = ImageButton(Config.IMAGE_ROOT + 'record.png' , Config.IMAGE_ROOT + 'recordhi.png', Config.IMAGE_ROOT + 'recordsel.png')
+ self.tooltips.set_tip(synthRecBtn,Tooltips.RECLAB)
+
+ synthBtn.connect('clicked', self.handleInstrumentButtonClick, n)
+ synthRecBtn.connect('clicked', self.handleSynthButtonClick, n)
+ synthRecBtn.connect('pressed', self.handleRecButtonPress, synthBtn)
+
+ vbox2.add(synthRecBtn)
+ vbox2.add(synthBtn)
+ hbox.add(vbox2)
+
+ self.leftBox.add(hbox)
+
+ def recordStateButton( self, state ):
+ self.seqRecordButton.set_active( state )
+
+ def handleInstrumentButtonClick(self , widget , instrument):
+ if widget.get_active() == True and self.recstate == False:
+ self.setInstrument(instrument)
+ self.playInstrumentNote(instrument)
+
+ def handleRecButtonPress(self, widget, recBtn):
+ self.recstate = True
+ recBtn.set_active(True)
+
+ def handleMicButtonClick(self , widget , data):
+ self.recstate = False
+ self.setInstrument(data)
+ if data == 'mic1':
+ self.csnd.micRecording(7)
+ elif data == 'mic2':
+ self.csnd.micRecording(8)
+ elif data == 'mic3':
+ self.csnd.micRecording(9)
+ elif data == 'mic4':
+ self.csnd.micRecording(10)
+ else:
+ return
+
+ def handleSynthButtonClick(self , widget , data):
+ self.recstate = False
+ self.setInstrument(data)
+ if data == 'lab1':
+ self.synthLabWindow1.show_all()
+ elif data == 'lab2':
+ self.synthLabWindow2.show_all()
+ elif data == 'lab3':
+ self.synthLabWindow3.show_all()
+ elif data == 'lab4':
+ self.synthLabWindow4.show_all()
+ else:
+ return
+
+ def handleGenerationSlider(self, adj):
+ img = int(adj.value * 7)+1
+ self.geneSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'complex' + str(img) + '.png')
+
+ def handleGenerationSliderRelease(self, widget, event):
+ self.regularity = widget.get_adjustment().value
+ self.rythmPlayer.notesList = generator( self.rythmInstrument, self.beat, self.regularity, self.reverb, self.csnd)
+
+ def handleBeatSlider(self, adj):
+ img = self.scale(int(adj.value),2,12,1,11)
+ self.beatSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'beat' + str(img) + '.png')
+ print img
+
+ def handleBeatSliderRelease(self, widget, event):
+ self.beat = int(widget.get_adjustment().value)
+ self.rythmPlayer.beat = self.beat
+ self.rythmPlayer.notesList = generator( self.rythmInstrument, self.beat, self.regularity, self.reverb, self.csnd)
+
+ def handleVolumeSlider(self, adj):
+ self.volume = int(adj.value)
+ self.csnd.setMasterVolume(self.volume)
+ img = int(self.scale(self.volume,0,100,0,3.9))
+ self.volumeSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'volume' + str(img) + '.png')
+
+ def handleReverbSlider(self, adj):
+ self.reverb = adj.value
+ img = int(self.scale(self.reverb,0,1,0,4))
+ self.reverbSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'reverb' + str(img) + '.png')
+ self.keyboardStandAlone.setReverb(self.reverb)
+
+ def handlePlayButton(self, widget, data = None):
+ if widget.get_active() == False:
+ self.rythmPlayer.stopPlayback()
+ else:
+ self.rythmPlayer.startPlayback()
+
+ def handleGenerationDrumBtn(self , widget , data):
+ self.rythmInstrument = data
+ if self.rythmPlayer.notesList:
+ for seq in self.rythmPlayer.notesList:
+ for note in seq:
+ note.instrument = data
+
+ def handleGenerateBtn(self , widget , data=None):
+ self.rythmPlayer.beat = self.beat
+ self.rythmPlayer.notesList = generator( self.rythmInstrument, self.beat, self.regularity, self.reverb, self.csnd)
+ self.rythmPlayer.startPlayback()
+ self.playStopButton.set_active(True)
+ self.playStartupSound()
+
+ def enableKeyboard( self ):
+ self.keyboardStandAlone = KeyboardStandAlone( self.csnd, self.rythmPlayer.recording, self.rythmPlayer.adjustDuration, self.rythmPlayer.getCurrentTick )
+ self.add_events(gtk.gdk.BUTTON_PRESS_MASK)
+
+ def setInstrument( self , instrument ):
+ self.instrument = instrument
+ self.keyboardStandAlone.setInstrument(instrument)
+
+ def setTempo(self,adj):
+ self.rythmPlayer.setTempo(int(adj.value))
+ img = int((adj.value - 40) /26.)+1
+ self.tempoSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'tempo' + str(img) + '.png')
+
+ def playInstrumentNote(self , instrument):
+ note = NoteStdAlone( client = self.csnd,
+ onset = 0,
+ pitch = 36,
+ amplitude = 1,
+ pan = 0.5,
+ duration = 20,
+ trackID = 1,
+ fullDuration = False,
+ instrument = instrument,
+ instrumentFlag = instrument,
+ reverbSend = 0)
+ note.play()
+
+ def playStartupSound(self):
+ r = str(random.randrange(1,11))
+ self.playInstrumentNote('guidice' + r)
+
+ def getInstrumentList(self):
+ cleanInstrumentList = [instrument for instrument in Config.INSTRUMENTS.keys() if instrument[0:4] != 'drum' and instrument[0:3] != 'mic' and instrument[0:3] != 'lab' and instrument[0:4] != 'guid']
+ cleanInstrumentList.sort(lambda g,l: cmp(Config.INSTRUMENTS[g].category, Config.INSTRUMENTS[l].category) )
+ return cleanInstrumentList + ['drum1kit', 'drum2kit', 'drum3kit']
+
+ def destroy( self, widget ):
+ gtk.main_quit()
+
+ def scale(self, input,input_min,input_max,output_min,output_max):
+ range_input = input_max - input_min
+ range_output = output_max - output_min
+ result = (input - input_min) * range_output / range_input + output_min
+
+ if (input_min > input_max and output_min > output_max) or (output_min > output_max and input_min < input_max):
+ if result > output_min:
+ return output_min
+ elif result < output_max:
+ return output_max
+ else:
+ return result
+
+ if (input_min < input_max and output_min < output_max) or (output_min < output_max and input_min > input_max):
+ if result > output_max:
+ return output_max
+ elif result < output_min:
+ return output_min
+ else:
+ return result
+
+if __name__ == "__main__":
+ standAlonePlayer = StandAlonePlayer()
+ #start the gtk event loop
+ gtk.main()
diff --git a/Player/StandalonePlayerOld.py b/Player/StandalonePlayerOld.py
index cc03ab4..c95c381 100644
--- a/Player/StandalonePlayerOld.py
+++ b/Player/StandalonePlayerOld.py
@@ -9,6 +9,8 @@ from Framework.CSound.CSoundConstants import CSoundConstants
from Player.KeyboardStandAlone import KeyboardStandAlone
from Player.NoteStdAlone import NoteStdAlone
+raise 'dont use this class, its the old one'
+
class StandAlonePlayer( gtk.Window ):
def __init__(self):
@@ -173,4 +175,4 @@ class StandAlonePlayer( gtk.Window ):
if __name__ == "__main__":
standAlonePlayer = StandAlonePlayer()
#start the gtk event loop
- gtk.main() \ No newline at end of file
+ gtk.main()