Example #1
0
 def create_bar(self, barIndex):
     self.bar_tick = quantize_tick_up(self.scheduler.get_tick())
     self.active_gems = self.gems[barIndex]
     # print(list(map(lambda x: x.beat, self.active_gems)))
     # [gem.activate() for gem in self.active_gems]
     self._initializeBarAudio(barIndex)
     self._initializeBarGems(barIndex)
Example #2
0
 def start(self):
     if self.playing:
         return
     self.playing = True
     now = self.sched.get_tick()
     next_beat = quantize_tick_up(now, self.beat_len)
     self.on_cmd = self.sched.post_at_tick(self.tick, next_beat)
Example #3
0
    def start(self):
        if self.playing:
            return

        self.playing = True
        self.noteIndex = 0
        self.shouldCallBack = False

        # set up the correct sound (program: bank and preset)
        self.synth.program(self.channel, self.program[0], self.program[1])

        # find the tick of the next beat, and make it "beat aligned"
        now = self.sched.get_tick()
        self.next_beat = quantize_tick_up(now, 480)

        #Since we are now supporting chords,
        #all notes need to be scheduled now
        for note in self.notes:
            ticksDeep = 480 * note[1]
            cmd = self.sched.post_at_tick(self._noteon,
                                          (self.next_beat + ticksDeep))
            self.cmds.append(
                cmd)  #remember to remember the commands incase we need to stop
            #print("note is at", note[1])
        cmd = self.sched.post_at_tick(self._killself,
                                      (self.next_beat + 480 * 16 - 40))
        self.cmds.append(cmd)
Example #4
0
    def start_playing(self):
        if self.playing:
            return
        self.metro.stop()
        self.playing = True

        now = self.sched.get_tick()
        next_beat = quantize_tick_up(now, kTicksPerQuarter * 4)
        self.cmd = self.sched.post_at_tick(self.play_recording, next_beat)
Example #5
0
    def start(self):
        if self.playing:
            return

        self.playing = True
        self.synth.program(self.channel, self.program[0], self.program[1])

        # post the first note on the next quarter-note:
        now = self.sched.get_tick()
        tick = quantize_tick_up(now, kTicksPerQuarter)
        self.on_cmd = self.sched.post_at_tick(self._note_on, tick, 0)
Example #6
0
    def start(self):
        if self.playing:
            return

        self.playing = True
        self.synth.program(self.channel, self.program[0], self.program[1])

        # start from the beginning
        self.idx = 0

        # post the first note on the next quarter-note:
        now = self.sched.get_tick()
        next_beat = quantize_tick_up(now, kTicksPerQuarter)
        self.cmd = self.sched.post_at_tick(self._note_on, next_beat)
Example #7
0
    def start(self):
        if self.playing:
            return

        self.playing = True

         # set up the correct sound (program: bank and preset)
        self.synth.program(self.channel, self.program[0], self.program[1])

        # find the tick of the next beat, and make it "beat aligned"
        now = self.sched.get_tick()
        next_beat = quantize_tick_up(now, self.length)

        # now, post the _noteon function (and remember this command)
        self.cmd = self.sched.post_at_tick(self._noteon, next_beat)
Example #8
0
    def __init__(self, norm, pos, tempo, clock, tempo_map, touch_points,
                 block_handler):
        super(TempoCursor, self).__init__()
        self.norm = norm
        self.pos = pos
        self.size = self.norm.nt((70, 70))

        self.cursor = CEllipse(cpos=pos, csize=self.size)
        self.add(Color(1, 1, 1))
        self.add(self.cursor)

        self.tempo = tempo
        self.clock = clock
        self.tempo_map = tempo_map
        self.sched = Scheduler(self.clock, self.tempo_map)

        self.block_handler = block_handler

        # 0..15, for 16th note granularity
        self.touch_points = touch_points
        self.index = 0

        # add touch markers
        self.add(PushMatrix())
        self.add(Translate(*pos))
        for touch_point in self.touch_points:
            self.add(Rotate(angle=-360 * touch_point / 16))
            self.add(Color(159 / 255, 187 / 255, 208 / 255))  # blue
            self.add(Line(points=(0, 0, 0, self.norm.nv(25)), width=2))
            self.add(Rotate(angle=360 * touch_point / 16))
        self.add(PopMatrix())

        # add current time marker
        self.add(PushMatrix())
        self.add(Translate(*pos))
        self.time_marker = Line(points=(0, 0, 0, self.norm.nv(30)), width=3)
        self.rotate = Rotate(angle=0)
        self.add(self.rotate)
        self.add(Color(0, 0, 0))
        self.add(self.time_marker)
        self.add(PopMatrix())

        self.on_update(0)

        cur_tick = self.sched.get_tick()
        next_tick = quantize_tick_up(cur_tick, kTicksPerQuarter * 4)
        next_tick += self.calculate_tick_interval(0, self.touch_points[0])
        self.sched.post_at_tick(self.touch_down, next_tick)
Example #9
0
 def _initializeBarGems(self, barIndex):
     slackWinOffset = quantize_tick_up(
         float(self.slack_timout) / 2 * kTicksPerQuarter)
     bar_tick = int(self.bar_tick)
     bar = self.gems[barIndex]
     for i in range(self.numRepeats):
         for gem in bar:
             tick = bar_tick + gem.beat * kTicksPerQuarter
             if i > 0:
                 self.gem_commands.append(
                     self.scheduler.post_at_tick(self._startGemTimer,
                                                 tick - slackWinOffset,
                                                 gem))
                 ticks_to_time(tick - slackWinOffset, self.bpm)
         bar_tick += self.barLenTicks
         self.gem_commands.append(
             self.scheduler.post_at_tick(self._onCompleteMeasure, bar_tick))
Example #10
0
    def __init__(self):
        super(MainWidget3, self).__init__()

        self.audio = Audio(2)
        self.synth = Synth('../data/FluidR3_GM.sf2')

        # create TempoMap, AudioScheduler
        self.tempo_map  = SimpleTempoMap(104)
        self.sched = AudioScheduler(self.tempo_map)

        # connect scheduler into audio system
        self.audio.set_generator(self.sched)
        self.sched.set_generator(self.synth)

        # create the metronome:
        self.metro = Metronome(self.sched, self.synth)        

        percNotes = [(480,35), (360,42), (120,35), (480,35), (480,42)]

        
        self.base1Notes = [(240,43), (240,43), (240,43), (120,47), (240,41), (240,41), (360,41), (120,40),
                      (360,41), (240,41), (240,41), (120,40), (120,36), (480,-1), (120,40), (240,41), (120,43)]

        self.base2Notes = [(120,-1), (120,45), (240,43), (120,-1), (240,43), (120,40), (480,43), (120,-1), (120,45), (120,45), (120,48),
                      (240,-1), (240,41), (120,-1), (240,41), (120,40), (480,41), (120,-1), (120,45), (120,45), (120,48),
                      (240,-1), (240,45), (120,-1), (240,45), (120,45), (480,45), (240,43), (120,-1), (120,45),
                      (240,-1), (240,45), (120,-1), (240,45), (120,45), (480,45), (120,-1), (120,45), (120,45), (120,48)]  
        
        self.baseNotes = self.base2Notes
        #[40, 41, 43, 45 48,]


        #changes / pitch sutff
        self.changes = [ (1920, [72, 74, 76, 79, 81, 84]),
                    (1920, [69, 72, 74, 81]),
                    (3840, [69, 72, 74, 76, 79, 81, 84])]

        self.changesIndex = 0
        self.curChanges = []
        self.selectSize = 2
        self.lastPitchIndex = None
        self.lastTouch = None


        #Note length stuff
        self.noteLengths = [480, 240, 120]
        self.articulation = 1
        self.lastPulseIndex = 0

        #Declare the players
        self.perc = NoteSequencer(self.sched, self.synth, 1, (128,0), percNotes)
        self.base1 = NoteSequencer(self.sched, self.synth, 2, (0,33), self.base1Notes, callback = self.graphic_callback)
        self.base2 = NoteSequencer(self.sched, self.synth, 2, (0,33), self.base2Notes, callback = self.graphic_callback)
        self.lead = Arpeggiator(self.sched, self.synth, channel = 3, program = (0,65), callback = self.graphic_callback)
        self.lead.set_direction('updown')
        #Start the non-interactive stuff
        now = self.sched.get_tick()
        next_beat = quantize_tick_up(now, 480)
        self.perc.toggle()
        self.base2.toggle()
        self.sched.post_at_tick(self._updateChanges, next_beat) #Update changes as music starts
        self.sched.post_at_tick(self._spawnCrossBar, next_beat)


        # and text to display our status
        #self.label = topleft_label()
        #self.add_widget(self.label)

        #Graphics stuff
        self.objects = AnimGroup()
        self.canvas.add(self.objects)
        #self.allNotes = [40, 41, 43, 45, 48, 900, 69, 72, 74, 76, 79, 81, 84]
        self.allNotes = [36, 40, 41, 43, 45, 47, 48, 900, 69, 72, 74, 76, 79, 81, 84]
Example #11
0
 def getTick(self):
     return quantize_tick_up(self.scheduler.get_tick())
Example #12
0
 def getRelativeTick(self):
     tick = quantize_tick_up(self.scheduler.get_tick())
     tick = (tick - self.bar_tick) % self.barLenTicks
     return tick