Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/python 2 # -*- coding: latin-1 -*- 3 4 """ 5 BaseComp. 6 7 A base composition module, custom composition classes should inherit from the BaseComp class. 8 9 @author: Øyvind Brandtsegg 10 @contact: obrandts@gmail.com 11 @license: GPL 12 """ 13 14 from constants import * 1517 """ 18 A base composition class, custom composition classes should inherit from this class. 19 """ 207422 """ 23 Class contructor. 24 25 @param self: The object pointer. 26 """ 27 28 self.isPlaying = False 29 """A flag indicating if the composition process should continue playing or not.""" 30 self.eventCaller = eventCaller 31 """Pointer to the event caller."""3234 """ 35 Handle the starting stopping or continuing of the composition process. 36 37 @param self: The object pointer. 38 @param state: The playback state, can be START, CONTINUE, STOP 39 @param beat: The current beat count of the timed queue (self.eventCaller.theTime), may be fractional. This parameter is optional; if it is not supplied, the current beat count (integer) will be polled from theTime. 40 """ 41 if beat == 0: beat = self.eventCaller.theTime.getCurrentBeat() 42 if state == START: # does nothing but put a randMelody event in the timed queue 43 if self.isPlaying != True: 44 self.eventCaller.theTime.insertQueue(beat+1, [self.perform]) 45 self.isPlaying = True 46 elif state == CONTINUE: # play a note and put an event in the timed queue 47 if self.isPlaying: 48 delta = self.playEvent() 49 self.eventCaller.theTime.insertQueue(beat+delta, [self.perform]) 50 elif state == STOP: # stop playing and remove any pending events for this instance of randMelody 51 self.isPlaying = False 52 for event in self.eventCaller.theTime.getQueue(): 53 if [self.perform] == event[1]: 54 self.eventCaller.theTime.removeEvent(event)5557 """ 58 Get event data from composition method, play event to Csound, insert "next" event in theTime queue. 59 60 @param self: The object pointer. 61 """ 62 instrument, amp, pitch, delta, duration, pan, reverb = self.getData() 63 duration = duration * (60.0/self.eventCaller.theTime.bpm) 64 self.eventCaller.csMessages.csoundInputMessage('i %i 0 %f %f %i %f %f'%(instrument, duration, amp, pitch, pan, reverb)) 65 return delta6668 """ 69 Get parameter values for the next event in the composition. You should override this method with something useful. 70 71 @param self: The object pointer. 72 """ 73 return 1,2,3,4,5,6,7
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0alpha3 on Mon Feb 23 14:31:59 2009 | http://epydoc.sourceforge.net |