示例#1
0
def expect(*notes):
    """
    Expect one or more notes to be heard.
    """
    
    notes = [Note.parse(note) for note in notes]
    _current_run.expect(notes)
示例#2
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
示例#3
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
示例#4
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:
示例#5
0
                profile = Profile(profile_name, path=path)
            else:
                raise
        except ProfileReadError, e:
            parser.error("invalid profile: %s" % e)

    capturer = Capturer(create_listener(options))

    targets = []
    is_range = False
    for arg in args:
        if arg == "-":
            is_range = True
            continue

        note = Note.parse(arg)
        if is_range:
            start = targets[-1].semitone + 1
            for i in xrange(start, note.semitone + 1):
                targets.append(Note.from_semitone(i))
        else:
            targets.append(note)

    capturer.start()
    try:
        for target in targets:
            if options.harmonics:
                harmonics = target.get_harmonics(options.harmonics)
            else:
                harmonics = None
示例#6
0
     help='FFT interval')
 parser.add_option('-w', '--window-size', metavar='SAMPLES', type='int',
     help='FFT window size')
 parser.set_defaults(interval=1024, window_size=4096, track=False,
     debug=False, peaks=False, profile='piano')
 
 options, args = parser.parse_args()
 
 profile = None
 if options.profile:
     try:
         profile = load_profile(options.profile)
     except Exception, e:
         parser.error('error reading profile: %s' % e)
 
 watched = [Note.parse(arg) for arg in args]
 
 def show_components(components):
     watched_components = [components.get(note) for note in watched]
     
     def describe(component):
         if component is None:
             return ' ' * 14
         
         desc = '%-14s' % ('%5.1f, %s' % (component.intensity,
             component.state))
         if component.state is FADING and component.previous_state is RISING:
             return color('purple!', desc)
         elif component.state is RISING:
             return color('green', desc)
         elif component.state is FADING: