Esempio n. 1
0
    def save_info(self, folder, score, params): 
        def format_pitch(x, pos=None):
            if int(x) != x: import ipdb;ipdb.set_trace()
            return Note(int(x)).get_pitch_name()[:-1]

        def do_plot(p, fname):
            y= [i[1] for i in sorted(p, key=lambda x:x[0])]
            x= [i[0].pitch for i in sorted(p, key=lambda x:x[0])]
            e= pylab.plot(x, y, label='score profile', color='black')[0]
            e.axes.set_xlabel('Nota')
            e.axes.set_ylabel('Probabilidad')
            ax= e.axes.xaxis
            ax.set_major_formatter(ticker.FuncFormatter(format_pitch))
            ax.set_major_locator(ticker.MultipleLocator())
            pylab.savefig(os.path.join(folder, fname))
            pylab.close()

        do_plot(self.score_profile, 'prior-profile.png')
        from random import shuffle
        chords= list(set(Chord.chordlist(score, dict(self.score_profile), enable_prints=False)))
        shuffle(chords)
        chords= chords[:4]
        def chord_name(c):
            return '-'.join(n.get_pitch_name() for n in c.notes)
        for chord in chords:
            do_plot(self.pitches_distr(chord.notes), 'posterior-%s.png' % chord_name(chord))
Esempio n. 2
0
 def __call__(self, score):
     chords= Chord.chordlist(score, self.chord_size)
     res= []
     for chord in chords:
         duration_var= ConstantRandomVariable(chord.duration, 'duration')
         res.append((chord, {duration_var:chord.duration}))
     return res            
Esempio n. 3
0
 def start_creation(self):
     self.chordlist= Chord.chordlist(self.context_score, 3)
     #self.chords= {}
     self.chord_pos= []