Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOli <olivier.belanger@umontreal.ca>2007-08-15 06:39:59 (GMT)
committer Oli <olivier.belanger@umontreal.ca>2007-08-15 06:39:59 (GMT)
commit1b9d2cd2bd9e3135b2aedd16e8cebc59d483c088 (patch)
tree8f4c22571c68325fb730efa5f45d07046a1e3e2f
parentf5e6fbe03050917940ea5673adb6625971e7eb6d (diff)
dual instruments on melodic tracks
-rw-r--r--Edit/MainWindow.py45
-rw-r--r--Resources/univorc.csd49
-rw-r--r--Util/CSoundClient.py23
-rw-r--r--Util/CSoundNote.py46
-rw-r--r--Util/NoteDB.py17
5 files changed, 99 insertions, 81 deletions
diff --git a/Edit/MainWindow.py b/Edit/MainWindow.py
index ad42a25..15d0468 100644
--- a/Edit/MainWindow.py
+++ b/Edit/MainWindow.py
@@ -52,7 +52,7 @@ class MainWindow( SubActivity ):
for i in [6,7,8,9,10]:
self.csnd.setTrackVolume(100, i)
self.trackCount = 6
-
+
# Toolbar
self.activity.activity_toolbar.keep.show()
self._mainToolbar = mainToolbar(self.activity.toolbox, self)
@@ -79,6 +79,9 @@ class MainWindow( SubActivity ):
if len(self.trackInstrument) != Config.NUMBER_OF_TRACKS: raise 'error'
self.drumIndex = Config.NUMBER_OF_TRACKS - 1
+ #second instrument for melodic tracks
+ self.trackInstrument2Default = [ Config.INSTRUMENTS["harmonica"], None, Config.INSTRUMENTS["rhodes"], None]
+ self.trackInstrument2 = self.trackInstrument2Default[:]
self._data['volume'] = Config.DEFAULT_VOLUME
self._data['tempo'] = Config.PLAYER_TEMPO
@@ -731,9 +734,6 @@ class MainWindow( SubActivity ):
Config.INSTRUMENTS[random.choice(keyboardPickup)],
Config.INSTRUMENTS[random.choice(drumsPickup)] ]
-# for tid in range(Config.NUMBER_OF_TRACKS):
-# self.handleInstrumentChanged( ( tid, self.trackInstrument[tid] ) )
-
def chooseGenParams(self):
choose = random.randint(0,4)
density = GenerationConstants.RYTHM_DENSITY_BANK[choose]
@@ -914,11 +914,25 @@ class MainWindow( SubActivity ):
self.page_onset[pid] = numticks
numticks += self.noteDB.getPage(pid).ticks
+ # check for a second instrument on melodic tracks
+ stream = []
+ for page in self.pages_playing:
+ for track in trackset:
+ if track != self.drumIndex:
+ if self.trackInstrument2[track] != None:
+ if len(self.noteDB.getNotesByTrack(page, track)):
+ stream += [ page, track, NoteDB.PARAMETER.INSTRUMENT2, len(self.noteDB.getNotesByTrack(page, track)) ]
+ for n in self.noteDB.getNotesByTrack(page, track):
+ stream += [ n.id, self.trackInstrument2[track].instrumentId ]
+ if len(stream):
+ self.noteDB.updateNotes( stream + [-1] )
+
notes = []
for page in self.pages_playing:
for track in trackset:
notes += self.noteDB.getNotesByTrack( page, track )
+
if (Config.DEBUG > 3):
print 'rebuild note loop'
print 'pages : ', self.pages_playing
@@ -989,7 +1003,7 @@ class MainWindow( SubActivity ):
def handleClose(self,widget):
self.activity.close()
-
+
def onTimeout(self):
self.updateFPS()
@@ -1050,17 +1064,6 @@ class MainWindow( SubActivity ):
pages = self.tuneInterface.getSelectedIds()
self.noteDB.setInstrument( pages, id, instrument.instrumentId )
- #self.noteLooper.setInstrument(id, instrumentName)
-
- #recordButton = self.instrumentRecordButtons[ id ]
- #if instrumentName in Config.RECORDABLE_INSTRUMENTS:
- # recordButton.show()
- # recordButton.connect( "clicked",
- # self.handleMicRecord,
- # Config.RECORDABLE_INSTRUMENT_CSOUND_IDS[ instrumentName ] )
- #else:
- # recordButton.hide()
-
def getScale(self):
return self.generationPanel.scale
@@ -1093,7 +1096,7 @@ class MainWindow( SubActivity ):
def handleToolClick( self, widget, mode ):
if widget.get_active(): self.trackInterface.setInterfaceMode( mode )
-
+
def handleToolClick2( self, widget, mode ):
self.trackInterface.setInterfaceMode( mode )
@@ -1214,7 +1217,7 @@ class MainWindow( SubActivity ):
beatsOfPages[pageId] = self.noteDB.pages[pageId].beats
instruments = self.noteDB.getInstruments(newpages)
-
+
#[ i.name for i in self.trackInstrument ],
algo(
params,
@@ -1529,7 +1532,7 @@ class MainWindow( SubActivity ):
self.GUI["9generationPopup"].move( balloc.x + winLoc[0], balloc.y - walloc.height + winLoc[1] )
else:
self.GUI["9generationPopup"].hide()
-
+
def setPageGenerateMode(self, mode):
self.generateMode = mode
@@ -2062,12 +2065,12 @@ class MainWindow( SubActivity ):
if self.context == CONTEXT.PAGE: self.GUI["2pageBox"].show()
elif self.context == CONTEXT.TRACK: self.GUI["2trackBox"].show()
else: self.GUI["2noteBox"].show()
-
+
if self.context == CONTEXT.NOTE:
self._mainToolbar.generationButton.set_sensitive(False)
else:
self._mainToolbar.generationButton.set_sensitive(True)
-
+
def getContext(self):
return self.context
diff --git a/Resources/univorc.csd b/Resources/univorc.csd
index 315b1f8..7418c35 100644
--- a/Resources/univorc.csd
+++ b/Resources/univorc.csd
@@ -500,8 +500,8 @@ arev butterlp arev, 5000
aLeft butterlp gaoutL, 7500
aRight butterlp gaoutR, 7500
-aOutLeft = (arev + aLeft) * koutGain * gkduck
-aOutRight = (arev + aRight) * koutGain * gkduck
+aOutLeft dcblock (arev + aLeft) * koutGain * gkduck
+aOutRight dcblock (arev + aRight) * koutGain * gkduck
gaRecL = aOutLeft
gaRecR = aOutRight
outs aOutLeft, aOutRight
@@ -802,19 +802,13 @@ endin
/****************************************************************
Soundfile player with miniTamTam's tied notes
****************************************************************/
-instr 5999
-
-/* gkptime times */
-gkrtime rtclock
-/* giptime times */
-girtime rtclock
-
-endin
/*************************
pitch, reverbGain, amp, pan, table, att, dec, filtType, cutoff, loopstart, loopend, crossdur
*************************/
instr 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010
+idump = p16
+
iTrackId = int(p1-5001)
SvolTrackName sprintf "trackVolume%0d", iTrackId
kvol chnget SvolTrackName
@@ -909,6 +903,12 @@ Soundfile player with edit's looped notes
*************************/
instr 5101, 5102, 5103, 5104, 5105, 5106, 5107, 5108, 5109, 5110
+if p16 != -1 then
+ inum = frac(p16) * 10000
+ itable2 = int(p16)
+ event_i "i", inum, 0, p3, p4, p5, p6, p7, itable2, p9, p10, p11, p12, p13, p14, p15, -1
+endif
+
ipitch random p4*.995, p4*1.005
iTrackId = int(p1-5101)
@@ -948,23 +948,13 @@ gainrev = a1*p5+gainrev
endin
/**************************************************************
-Simple soundfile player
+Simple soundfile player (miniTamTam)
**************************************************************/
-instr 5777
-
-/*iptime = i(gkptime) */
-irtime = i(gkrtime)
-/*icurptime = iptime - giptime */
-/*icurlag = irtime - iptime - (girtime - giptime) */
-i2 = p5 - (irtime - girtime) + 0.1
-
-event_i "i", p4, i2, p6, p7, p8, p9, p10, p11, p12, p13, p14
-
-endin
-
instr 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020
+idump = p16
+
iTrackId = int(p1-5011)
SvolTrackName3 sprintf "trackVolume%0d", iTrackId
kvol chnget SvolTrackName3
@@ -990,8 +980,7 @@ endif
a1 tone a1, ialias
kenv adsr p9, 0.05, .8, p10
-
-a1 = a1*kenv*kvol
+a1 = a1*kenv*kvol
gaoutL = a1*(1-p7)+gaoutL
gaoutR = a1*p7+gaoutR
@@ -1000,8 +989,18 @@ gainrev = a1*p5+gainrev
endin
+/**************************************************************
+Simple soundfile player (Edit)
+**************************************************************/
+
instr 5111, 5112, 5113, 5114, 5115, 5116, 5117, 5118, 5119, 5120
+if p16 != -1 then
+ inum = frac(p16) * 10000
+ itable2 = int(p16)
+ event_i "i", inum, 0, p3, p4, p5, p6, p7, itable2, p9, p10, p11, p12, p13, p14, p15, -1
+endif
+
iTrackId = int(p1-5111)
SvolTrackName4 sprintf "trackVolume%0d", iTrackId
kvol chnget SvolTrackName4
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py
index 0a10d21..8cc9ec2 100644
--- a/Util/CSoundClient.py
+++ b/Util/CSoundClient.py
@@ -26,7 +26,8 @@ class _CSoundClientPlugin:
ATTACK, \
DECAY, \
FILTERTYPE, \
- FILTERCUTOFF ) = range(12)
+ FILTERCUTOFF, \
+ INSTRUMENT2 ) = range(13)
def __init__(self):
sc_initialize( Config.PLUGIN_UNIVORC, Config.PLUGIN_DEBUG,
@@ -204,9 +205,12 @@ class _CSoundClientPlugin:
sc_loop_updateEvent( (page<<16)+id, self.FILTERTYPE, value, cmd)
elif (parameter == NoteDB.PARAMETER.FILTERCUTOFF):
sc_loop_updateEvent( (page<<16)+id, self.FILTERCUTOFF, value, cmd)
+ elif (parameter == NoteDB.PARAMETER.INSTRUMENT2):
+ sc_loop_updateEvent( (page<<16)+id, self.INSTRUMENT2, value, cmd)
else:
if (Config.DEBUG > 0): print 'ERROR: loopUpdate(): unsupported parameter change'
+
def loopPlay(self, dbnote, active):
qid = (dbnote.page << 16) + dbnote.id
sc_loop_addScoreEvent( qid, 1, active, 'i', self.csnote_to_array(dbnote.cs))
@@ -233,7 +237,8 @@ class _CSoundClientPlugin:
csnote.filterCutoff,
csnote.tied,
csnote.instrumentId,
- csnote.mode)
+ csnote.mode,
+ csnote.instrumentId2 )
def csnote_to_array1( self, onset,
pitch,
@@ -248,7 +253,8 @@ class _CSoundClientPlugin:
filterCutoff = 1000,
tied = False,
instrumentId = Config.INSTRUMENTS["flute"].instrumentId,
- mode = 'edit' ):
+ mode = 'edit',
+ instrumentId2 = -1 ):
instrument = Config.INSTRUMENTSID[instrumentId]
if instrument.kit != None:
@@ -281,6 +287,14 @@ class _CSoundClientPlugin:
instrument_id_offset = 0
else:
instrument_id_offset = 100
+
+ if instrumentId2 != -1:
+ instrument2 = Config.INSTRUMENTSID[instrumentId2]
+ csInstrumentId2 = (instrument2.csoundInstrumentId + 100) * 0.0001
+ secondInstrument = Config.INSTRUMENT_TABLE_OFFSET + instrumentId2 + csInstrumentId2
+ else:
+ secondInstrument = -1
+
a = array.array('f')
a.extend( [
(instrument.csoundInstrumentId + (trackId+1) + instrument_id_offset) + trackId * 0.01,
@@ -297,7 +311,8 @@ class _CSoundClientPlugin:
filterCutoff,
instrument.loopStart,
instrument.loopEnd,
- instrument.crossDur ])
+ instrument.crossDur,
+ secondInstrument ])
return a
diff --git a/Util/CSoundNote.py b/Util/CSoundNote.py
index d41fc11..7b2019e 100644
--- a/Util/CSoundNote.py
+++ b/Util/CSoundNote.py
@@ -1,23 +1,23 @@
import Config
-from Generation.GenerationConstants import GenerationConstants
class CSoundNote :
def __init__( self,
- onset,
- pitch,
- amplitude,
- pan,
- duration,
- trackId,
- instrumentId = Config.INSTRUMENTS["flute"].instrumentId,
- attack = 0.002,
- decay = 0.098,
- reverbSend = 0.1,
- filterType = 0,
+ onset,
+ pitch,
+ amplitude,
+ pan,
+ duration,
+ trackId,
+ instrumentId = Config.INSTRUMENTS["flute"].instrumentId,
+ attack = 0.005,
+ decay = 0.098,
+ reverbSend = 0.1,
+ filterType = 0,
filterCutoff = 1000,
tied = False,
- mode = 'edit' ):
-
+ mode = 'edit',
+ instrumentId2 = -1 ):
+
self.onset = onset
self.pitch = pitch
self.amplitude = amplitude
@@ -34,6 +34,14 @@ class CSoundNote :
self.filterCutoff = filterCutoff
self.tied = tied
self.mode = mode
+ self.instrumentId2 = instrumentId2
+
+ def clone( self ):
+ return CSoundNote( self.onset, self.pitch, self.amplitude, self.pan,
+ self.duration, self.trackId, self.instrumentId,
+ self.attack, self.decay, self.reverbSend,
+ self.filterType, self.filterCutoff, self.tied,
+ self.mode, self.instrumentId2 )
def __getstate__unused(self):
return {'onset': self.onset,
@@ -67,13 +75,3 @@ class CSoundNote :
self.tied = dict['tied']
self.mode = dict['mode']
self.nchanges = 0
-
- def clone( self ):
- return CSoundNote( self.onset, self.pitch, self.amplitude, self.pan,
- self.duration, self.trackId, self.instrumentId,
- self.attack, self.decay, self.reverbSend,
- self.filterType, self.filterCutoff, self.tied,
- self.mode )
-
-
-
diff --git a/Util/NoteDB.py b/Util/NoteDB.py
index f6ec5de..d334670 100644
--- a/Util/NoteDB.py
+++ b/Util/NoteDB.py
@@ -14,8 +14,9 @@ class PARAMETER:
ATTACK, \
DECAY, \
FILTERTYPE, \
- FILTERCUTOFF \
- = range(13) #python-stye enum
+ FILTERCUTOFF, \
+ INSTRUMENT2 \
+ = range(14) #python-stye enum
class Note:
def __init__( self, page, track, id, cs ):
@@ -30,7 +31,7 @@ class Page:
self.ticks = beats*Config.TICKS_PER_BEAT
self.color = color
-
+
if not instruments:
self.instruments = [ Config.INSTRUMENTS["kalimba"].instrumentId for i in range(Config.NUMBER_OF_TRACKS-1) ] + [ Config.INSTRUMENTS["drum1kit"].instrumentId ]
else:
@@ -213,7 +214,7 @@ class NoteDB:
i += 1
self.tune = self.tune[:at] + sorted + self.tune[at:]
-
+
#self._updateBeatsBefore( low )
for l in self.pageListeners:
@@ -242,9 +243,9 @@ class NoteDB:
self.deleteNotes( dstream + [-1] )
if len(ustream):
self.updateNotes( ustream + [-1] )
-
+
self.pages[page].beats = value
- self.pages[page].ticks = ticks
+ self.pages[page].ticks = ticks
#self._updateBeatsBefore(self.tune.index(page))
elif parameter == PARAMETER.PAGE_COLOR:
self.pages[page].color = value
@@ -302,7 +303,7 @@ class NoteDB:
# for i in range(ind, len(self.tune)):
# self.beatsBefore[self.tune[ind]] = beats
# beats += self.pages[self.tune[ind]].beats
-
+
#=======================================================
@@ -482,6 +483,8 @@ class NoteDB:
self.noteD[page][track][id].cs.filterType = value
elif parameter == PARAMETER.FILTERCUTOFF:
self.noteD[page][track][id].cs.filterCutoff = value
+ elif parameter == PARAMETER.INSTRUMENT2:
+ self.noteD[page][track][id].cs.instrumentId2 = value
for par in self.parasiteList.keys():
self.parasiteD[page][track][par][id].updateParameter( parameter, value )