Пример #1
0
	def on_rotate(self, ccw):
		self.board.ClearDigitalChannel(self.index)
		if ccw:
			self.index = (self.index - 1) if self.index > 1 else 8
		else:
			self.index = (self.index + 1) if self.index < 8 else 1
		self.board.SetDigitalChannel(self.index)
		self.counter += 1
		print self.counter
		beep([self.counter], [5.0])
		return True
Пример #2
0
def main3():
	k = pyk8055.k8055(0)
	get_values(k)
	old_octave = 0
	all_frequencies = []
	all_durations = []
	try:
		while True:
			frequencies = []
			durations = []
			mask = VALUES[1]
			analog1 = VALUES[2]
			analog2 = float(VALUES[3])
			inputs = mask_to_bool_list(mask)
			true_inputs = float(len([input for input in inputs if input]))
			new_octave = divmod(analog1, 32)[0] + 1
			dur_mod = (analog2 / 127.0) ** 2
			thread.start_new_thread(get_values, (k, ))
			if new_octave != old_octave:
				k.ClearDigitalChannel(old_octave)
				k.SetDigitalChannel(new_octave)
				old_octave = new_octave
			if inputs[0]:
				frequencies.append(calculate_freq("C", new_octave, 0))
				durations.append((100.0 * dur_mod) / true_inputs)
			if inputs[1]:
				frequencies.append(calculate_freq("D", new_octave, 0))
				durations.append((100.0 * dur_mod) / true_inputs)
			if inputs[2]:
				frequencies.append(calculate_freq("E", new_octave, 0))
				durations.append((100.0 * dur_mod) / true_inputs)
			if inputs[3]:
				frequencies.append(calculate_freq("F", new_octave, 0))
				durations.append((100.0 * dur_mod) / true_inputs)
			if inputs[4]:
				frequencies.append(calculate_freq("G", new_octave, 0))
				durations.append((100.0 * dur_mod) / true_inputs)
			if mask > 0:
				beep(frequencies, durations)
				all_frequencies += frequencies
				all_durations += durations
	except KeyboardInterrupt:
		time.sleep(1)
		print "Replaying melody."
		beep(all_frequencies, all_durations)
Пример #3
0
def main3():
    k = pyk8055.k8055(0)
    get_values(k)
    old_octave = 0
    all_frequencies = []
    all_durations = []
    try:
        while True:
            frequencies = []
            durations = []
            mask = VALUES[1]
            analog1 = VALUES[2]
            analog2 = float(VALUES[3])
            inputs = mask_to_bool_list(mask)
            true_inputs = float(len([input for input in inputs if input]))
            new_octave = divmod(analog1, 32)[0] + 1
            dur_mod = (analog2 / 127.0)**2
            thread.start_new_thread(get_values, (k, ))
            if new_octave != old_octave:
                k.ClearDigitalChannel(old_octave)
                k.SetDigitalChannel(new_octave)
                old_octave = new_octave
            if inputs[0]:
                frequencies.append(calculate_freq("C", new_octave, 0))
                durations.append((100.0 * dur_mod) / true_inputs)
            if inputs[1]:
                frequencies.append(calculate_freq("D", new_octave, 0))
                durations.append((100.0 * dur_mod) / true_inputs)
            if inputs[2]:
                frequencies.append(calculate_freq("E", new_octave, 0))
                durations.append((100.0 * dur_mod) / true_inputs)
            if inputs[3]:
                frequencies.append(calculate_freq("F", new_octave, 0))
                durations.append((100.0 * dur_mod) / true_inputs)
            if inputs[4]:
                frequencies.append(calculate_freq("G", new_octave, 0))
                durations.append((100.0 * dur_mod) / true_inputs)
            if mask > 0:
                beep(frequencies, durations)
                all_frequencies += frequencies
                all_durations += durations
    except KeyboardInterrupt:
        time.sleep(1)
        print "Replaying melody."
        beep(all_frequencies, all_durations)
Пример #4
0
def main():
	k = pyk8055.k8055(0)
	get_values(k)
	while True:
		mask = VALUES[1]
		analog1 = float(VALUES[2])
		analog2 = float(VALUES[3])
		inputs = mask_to_bool_list(mask)
		freq_mod = (analog1 / 127.0) ** 2
		dur_mod = (analog2 / 127.0) ** 2
		thread.start_new_thread(get_values, (k, ))
		if inputs[0]:
			beep([100.0 * freq_mod], [100.0 * dur_mod])
		if inputs[1]:
			beep([200.0 * freq_mod], [100.0 * dur_mod])
		if inputs[2]:
			beep([300.0 * freq_mod], [100.0 * dur_mod])
		if inputs[3]:
			beep([400.0 * freq_mod], [100.0 * dur_mod])
		if inputs[4]:
			beep([500.0 * freq_mod], [100.0 * dur_mod])
Пример #5
0
def main():
    k = pyk8055.k8055(0)
    get_values(k)
    while True:
        mask = VALUES[1]
        analog1 = float(VALUES[2])
        analog2 = float(VALUES[3])
        inputs = mask_to_bool_list(mask)
        freq_mod = (analog1 / 127.0)**2
        dur_mod = (analog2 / 127.0)**2
        thread.start_new_thread(get_values, (k, ))
        if inputs[0]:
            beep([100.0 * freq_mod], [100.0 * dur_mod])
        if inputs[1]:
            beep([200.0 * freq_mod], [100.0 * dur_mod])
        if inputs[2]:
            beep([300.0 * freq_mod], [100.0 * dur_mod])
        if inputs[3]:
            beep([400.0 * freq_mod], [100.0 * dur_mod])
        if inputs[4]:
            beep([500.0 * freq_mod], [100.0 * dur_mod])
Пример #6
0
def main2():
	k = pyk8055.k8055(0)
	get_values(k)
	old_octave = 0
	while True:
		frequencies = []
		durations = []
		mask = VALUES[1]
		analog1 = VALUES[2]
		analog2 = float(VALUES[3])
		inputs = mask_to_bool_list(mask)
		true_inputs = float(len([input for input in inputs if input]))
		new_octave = divmod(analog1, 32)[0] + 1
		dur_mod = (analog2 / 127.0) ** 2
		thread.start_new_thread(get_values, (k, ))
		if new_octave != old_octave:
			k.ClearDigitalChannel(old_octave)
			k.SetDigitalChannel(new_octave)
			old_octave = new_octave
		if inputs[0]:
			frequencies.append(calculate_freq("C", new_octave, 0))
			durations.append((100.0 * dur_mod) / true_inputs)
		if inputs[1]:
			frequencies.append(calculate_freq("D", new_octave, 0))
			durations.append((100.0 * dur_mod) / true_inputs)
		if inputs[2]:
			frequencies.append(calculate_freq("E", new_octave, 0))
			durations.append((100.0 * dur_mod) / true_inputs)
		if inputs[3]:
			frequencies.append(calculate_freq("F", new_octave, 0))
			durations.append((100.0 * dur_mod) / true_inputs)
		if inputs[4]:
			frequencies.append(calculate_freq("G", new_octave, 0))
			durations.append((100.0 * dur_mod) / true_inputs)
		if len(frequencies) > 0:
			beep(frequencies, durations)
Пример #7
0
def main2():
    k = pyk8055.k8055(0)
    get_values(k)
    old_octave = 0
    while True:
        frequencies = []
        durations = []
        mask = VALUES[1]
        analog1 = VALUES[2]
        analog2 = float(VALUES[3])
        inputs = mask_to_bool_list(mask)
        true_inputs = float(len([input for input in inputs if input]))
        new_octave = divmod(analog1, 32)[0] + 1
        dur_mod = (analog2 / 127.0)**2
        thread.start_new_thread(get_values, (k, ))
        if new_octave != old_octave:
            k.ClearDigitalChannel(old_octave)
            k.SetDigitalChannel(new_octave)
            old_octave = new_octave
        if inputs[0]:
            frequencies.append(calculate_freq("C", new_octave, 0))
            durations.append((100.0 * dur_mod) / true_inputs)
        if inputs[1]:
            frequencies.append(calculate_freq("D", new_octave, 0))
            durations.append((100.0 * dur_mod) / true_inputs)
        if inputs[2]:
            frequencies.append(calculate_freq("E", new_octave, 0))
            durations.append((100.0 * dur_mod) / true_inputs)
        if inputs[3]:
            frequencies.append(calculate_freq("F", new_octave, 0))
            durations.append((100.0 * dur_mod) / true_inputs)
        if inputs[4]:
            frequencies.append(calculate_freq("G", new_octave, 0))
            durations.append((100.0 * dur_mod) / true_inputs)
        if len(frequencies) > 0:
            beep(frequencies, durations)