Beispiel #1
0
 def _get_potential_supporters(self, target, components):
     frequency = target.frequency
     harmonics = [Note.from_frequency(frequency * i)
         for i in [1.0 / n for n in range(2, 5)] + range(2, 5)]
     
     def is_supporter(note):
         if abs(note.semitone - target.semitone) <= 1:
             return False
         
         return note in harmonics
     
     potentials = [c for c in components if is_supporter(c.note)]
     potentials.sort(key=lambda c: c.previous_intensity, reverse=True)
     return potentials
Beispiel #2
0
 def _run(self):
     import traceback
     while True:
         with self._available:
             while not self._recording:
                 self._available.wait()
         
         try:
             for result in self._recording:
                 self._receiver([(Note.from_frequency(freq), intensity)
                     for freq, intensity in result])
         except Exception:
             traceback.print_exc()
         
         self._on_finish()
         self._recording = None
         self._on_finish = None
Beispiel #3
0
         parser.error('file not found: %s' % path)
     else:
         raise
 
 notes = map(Note.parse, args[1:])
 
 if isinstance(recording, dict) and 'results' in recording:
     results = recording['results']
 else:
     results = recording
 
 plotted_series = defaultdict(list)
 for result in results:
     needed = set(notes)
     for freq, intensity in result:
         note = Note.from_frequency(freq)
         if note in needed:
             needed.remove(note)
             plotted_series[note].append(intensity)
     
     for unfound in needed:
         plotted_series[unfound].append(0.0)
 
 colors = get_colors(len(notes))
 
 for i, color_info in enumerate(colors):
     print color(color_info[0], '%-3s', notes[i]),
 print
 
 plots = []
 for note in notes:
Beispiel #4
0
    
    tracker = ComponentTracker(callback)
    
    if options.track:
        # print note headings
        for note in watched:
            print color('black!', '%-3s%s', note, ' ' * 11),
        print
        for note in watched:
            print color('black!', '=' * 14),
        print
    
    if options.recording:
        # read the FFT results from a file created by audio/test.py
        with open(options.recording, 'rb') as stream:
            recording = pickle.load(stream)
        
        if isinstance(recording, dict) and 'results' in recording:
            results = recording['results']
        else:
            results = recording
        
        for buckets in results:
            buckets = [(Note.from_frequency(freq), intensity)
                for freq, intensity in buckets]
            tracker.update(buckets)
    else:
        # capture live
        capturer = Capturer(create_listener(options), tracker.update)
        capturer.run_until_interrupt()