示例#1
0
 def remapTrack(self, tobj, tau=None, vLow=-2, vHigh=2, inst=127, fch=None, res=None, repeats=None):
     if res == None:
         res = self.resolution
     if res == None:
         print "Cannot remap track without resolution"
         return
     mObj = MidiObj(resolution=res)
     T = tobj.getMaxTime()
     print "T:", T
     if tau == None:
         tau = T
     tau = T
     rmap = RissetMapper(T, tau)
     reMax = rmap.get_te(T,0)[0]
     print "rmap(T):", reMax
     ch = 0
     for v in range(vLow, vHigh+1):
         print "v: ", v
         #rtObj = self.remapv(tobj, v, tau, ch=ch, inst=10+v)
         if fch != None:
             ch = fch
         rtObj = self.remapv(tobj, v, tau, ch=ch, inst=inst)
         rtObj.trackName = "risset v=%s" % v
         if repeats:
             rt0 = TrackObj()
             for i in range(repeats):
                 rt0.append(rtObj)
             rtObj = rt0
         mObj.addTrack(rtObj)
         ch += 1
     #mObj.resolution = rtObj.resolution
     mObj.loop = True
     return mObj
示例#2
0
文件: Shepard.py 项目: sycgis/Spirals
    def gen(self, path, nnotes=200, motif=None):
        self.t = 0
        if motif:
            motif = parse(motif)
        print "="*60
        print "Generating Shepard Tones"
        tobj = TrackObj(trackName="Track1")
        for i in range(nnotes):
            dur = 1
            if motif:
                j,dur = motif[i % len(motif)]
                if j == 'r':
                    self.t += dur*self.ticksPerBeat
                    continue
            else:
                j = i % 12
            #print i, j
            notes = self.getChord(j, dur)
            self.t += dur*self.ticksPerBeat
            for note in notes:
                tobj.addNote(note)

        midiObj = MidiObj()
        midiObj.addTrack(tobj)
        midiObj.saveAsJSON(path)
        mpath = path.replace(".json", ".mid")
        midiObj.saveAsMidi(mpath)
示例#3
0
文件: risset.py 项目: sycgis/Spirals
def genTrackBasicBeat1(resolution):
    t = TrackObj()
    numMeasures = 8
    tpb = resolution  # ticks per beat
    bpmeasure = 4  # beats per measure
    for m in range(numMeasures):
        b = m * bpmeasure
        t0 = b * tpb
        print "b: %3d t: %8.3f" % (b, t0)
        #              c  p   t          v    dur
        t.addNote(Note(0, 50, t0, 90, 0.25 * tpb))
        t.addNote(Note(0, 50, t0 + 1 * tpb, 70, 0.25 * tpb))
        t.addNote(Note(0, 50, t0 + 2 * tpb, 70, 0.25 * tpb))
        t.addNote(Note(0, 50, t0 + 3 * tpb, 70, 0.25 * tpb))
    t.setMaxTime(t0 + bpmeasure * tpb)
    m = MidiObj(resolution=tpb)
    m.addTrack(t)
    return m
示例#4
0
def genTrackBasicBeat1(resolution):
    t = TrackObj()
    numMeasures = 8
    tpb = resolution  # ticks per beat
    bpmeasure = 4           # beats per measure
    for m in range(numMeasures):
        b = m*bpmeasure
        t0 = b * tpb
        print "b: %3d t: %8.3f" % (b, t0)
        #              c  p   t          v    dur
        t.addNote(Note(0, 50, t0,        90,  0.25*tpb))
        t.addNote(Note(0, 50, t0+1*tpb,  70,  0.25*tpb))
        t.addNote(Note(0, 50, t0+2*tpb,  70,  0.25*tpb))
        t.addNote(Note(0, 50, t0+3*tpb,  70,  0.25*tpb))
    t.setMaxTime(t0 + bpmeasure*tpb)
    m = MidiObj(resolution=tpb)
    m.addTrack(t)
    return m
示例#5
0
文件: risset.py 项目: sycgis/Spirals
 def remapTrack(self,
                tobj,
                tau=None,
                vLow=-2,
                vHigh=2,
                inst=127,
                fch=None,
                res=None,
                repeats=None):
     if res == None:
         res = self.resolution
     if res == None:
         print "Cannot remap track without resolution"
         return
     mObj = MidiObj(resolution=res)
     T = tobj.getMaxTime()
     print "T:", T
     if tau == None:
         tau = T
     tau = T
     rmap = RissetMapper(T, tau)
     reMax = rmap.get_te(T, 0)[0]
     print "rmap(T):", reMax
     ch = 0
     for v in range(vLow, vHigh + 1):
         print "v: ", v
         #rtObj = self.remapv(tobj, v, tau, ch=ch, inst=10+v)
         if fch != None:
             ch = fch
         rtObj = self.remapv(tobj, v, tau, ch=ch, inst=inst)
         rtObj.trackName = "risset v=%s" % v
         if repeats:
             rt0 = TrackObj()
             for i in range(repeats):
                 rt0.append(rtObj)
             rtObj = rt0
         mObj.addTrack(rtObj)
         ch += 1
     #mObj.resolution = rtObj.resolution
     mObj.loop = True
     return mObj
示例#6
0
    def gen(self, path, nnotes=200, motif=None):
        self.t = 0
        if motif:
            motif = parse(motif)
        print "="*60
        print "Generating Shepard Tones"
        tobj = TrackObj(trackName="Track1")
        for i in range(nnotes):
            dur = 1
            if motif:
                j,dur = motif[i % len(motif)]
            else:
                j = i % 12
            #print i, j
            notes = self.getChord(j, dur)
            for note in notes:
                tobj.addNote(note)

        midiObj = MidiObj()
        midiObj.addTrack(tobj)
        midiObj.saveAsJSON(path)
示例#7
0
def genShepard(path, nvoices=5, noctaves=5, nnotes=200, motif=None):
    if motif:
        motif = parse(motif)
    print "="*60
    print "Generating Shepard Tones"
    tobj = TrackObj(trackName="Track1")
    t = 0
    for v in range(nvoices):
        sv = ShepVoice(noctaves, 12*v)
        for i in range(nnotes):
            j = i
            dur = 1
            if motif:
                j,dur = motif[i % len(motif)]
            #print j, dur
            tOn, note = sv.getNote(t, j, dur)
            t += sv.ticksPerBeat*dur
            if note:
                #print i, note.toList()
                tobj.addNote(note)
    midiObj = MidiObj()
    midiObj.addTrack(tobj)
    midiObj.saveAsJSON(path)
示例#8
0
    def gen(self, path, nnotes=200, motif=None):
        self.t = 0
        if motif:
            motif = parse(motif)
        print "=" * 60
        print "Generating Shepard Tones"
        tobj = TrackObj(trackName="Track1")
        for i in range(nnotes):
            dur = 1
            if motif:
                j, dur = motif[i % len(motif)]
            else:
                j = i % 12
            #print i, j
            notes = self.getChord(j, dur)
            for note in notes:
                tobj.addNote(note)

        midiObj = MidiObj()
        midiObj.addTrack(tobj)
        midiObj.saveAsJSON(path)
示例#9
0
def genShepard(path, nvoices=5, noctaves=5, nnotes=200, motif=None):
    if motif:
        motif = parse(motif)
    print "=" * 60
    print "Generating Shepard Tones"
    tobj = TrackObj(trackName="Track1")
    t = 0
    for v in range(nvoices):
        sv = ShepVoice(noctaves, 12 * v)
        for i in range(nnotes):
            j = i
            dur = 1
            if motif:
                j, dur = motif[i % len(motif)]
            #print j, dur
            tOn, note = sv.getNote(t, j, dur)
            t += sv.ticksPerBeat * dur
            if note:
                #print i, note.toList()
                tobj.addNote(note)
    midiObj = MidiObj()
    midiObj.addTrack(tobj)
    midiObj.saveAsJSON(path)
示例#10
0
def save(tObj, path):
    mObj = MidiObj()
    mObj.addTrack(tObj)
    mObj.saveAsJSON(path)
示例#11
0
def save(tObj, path):
    mObj = MidiObj()
    mObj.addTrack(tObj)
    mObj.saveAsJSON(path)
示例#12
0
from PVMidi import TrackObj, MidiObj, Note


def save(tObj, path):
    mObj = MidiObj()
    mObj.addTrack(tObj)
    mObj.saveAsJSON(path)


path = "BluesRhythm1.mid"
m = MidiObj(path)
print m.tracks
t = m.tracks[1]
rt = t.rescaleByTime(t.rescaleTime(0.25, 2.0))
rt.scalePowerBySin()
save(rt, "ris1.json")