示例#1
0
    def send_note(self, inst, pitch, duration, vol, gy=-1):
        if not hasCSound:
            return

        if gy == -1:
            tid = 0
        else:
            tid = self.get_available_track()
            self.track_map[gy] = tid
        pitch = self.shift_pitch(inst, pitch)
        csnote = CSoundNote(0, pitch, vol * self.global_vol, 0.5, duration,
                            tid, inst)
        csnote.decay = 0.5
        self.csound.play(
            csnote,
            1)  # sec per tick = 1, so the unit for duration/decay becomes sec
示例#2
0
    def send_tied_note_off(self, inst, pitch, duration, decay, vol):
        if not hasCSound:
            return

        tid = self.query_pitch_and_recycle_tid(pitch)
        if tid == -1:
            return
        #print "pitch(" + str(pitch) + ") removed from track " + str(tid)
        pitch = self.shift_pitch(inst, pitch)

        csnote = CSoundNote(0, pitch, vol * self.global_vol, 0.5, duration,
                            tid, inst)
        csnote.decay = decay
        csnote.tied = False
        csnote.mode = "mini"

        self.csound.play(csnote, 1)
示例#3
0
    def send_loop_note(self, inst, pitch, time, duration, vol, lid):
        if not hasCSound:
            return

        #generate a CSoundNote: (onset_time (ticks), pitch (MIDI #), vol, pan, duration (ticks), track_id, inst_id)
        pitch = self.shift_pitch(inst, pitch)
        csnote = CSoundNote(time, pitch, vol * self.global_vol, 0.5, duration,
                            0, inst)
        if inst < 5:  # sustain piano sound for 0.15 sec
            csnote.duration = duration + self.time2tick(0.36)
        #elif inst == 141:
        #    csnote.duration = -1
        csnote.decay = self.time2tick(
            0.75)  # apply a decay for all instruments

        #wrap it in a Note before adding to the loop Note(page_id, track_id, note_id, csnote)
        n = Note(0, csnote.trackId, self.get_nid(), csnote)
        self.csound.loopPlay(n, 1, loopId=lid)