def song1_hiSpd(self): self.btnnum1_hiSpd.configure(image=self.btnnum1_hiSpd_change_gif) sampler = Sampler() s1 = Sound.from_file(song_name1) s1.stretch_factor = 2 sampler.play(s1) self.btnnum1_hiSpd.configure(image=self.btnnum1_hiSpd_gif)
def song1_lowKey(self): self.btnnum1_lowKey.configure(image=self.btnnum1_lowKey_change_gif) sampler = Sampler() s1 = Sound.from_file(song_name1) s1.pitch_shift = -1 sampler.play(s1) self.btnnum1_lowKey.configure(image=self.btnnum1_lowKey_gif)
def song2_hiSpd(self): self.btnnum2_hiSpd.configure(image=self.btnnum2_hiSpd_change_gif) sampler = Sampler() s2 = Sound.from_file(song_name2) s2.stretch_factor = 2 sampler.play(s2) self.btnnum2_hiSpd.configure(image=self.btnnum2_hiSpd_gif)
def song2_lowKey(self): self.btnnum2_lowKey.configure(image=self.btnnum2_lowKey_change_gif) sampler = Sampler() s2 = Sound.from_file(song_name2) s2.pitch_shift = -1 sampler.play(s2) self.btnnum2_lowKey.configure(image=self.btnnum2_lowKey_gif)
def song4_lowKey(self): self.btnnum4_lowKey.configure(image=self.btnnum4_lowKey_change_gif) sampler = Sampler() s4 = Sound.from_file(song_name4) s4.pitch_shift = -1 sampler.play(s4) self.btnnum4_lowKey.configure(image=self.btnnum4_lowKey_gif)
def song3_lowKey(self): self.btnnum3_lowKey.configure(image=self.btnnum3_lowKey_change_gif) sampler = Sampler() s3 = Sound.from_file(song_name3) s3.pitch_shift = -1 sampler.play(s3) self.btnnum3_lowKey.configure(image=self.btnnum3_lowKey_gif)
def song3_hiSpd(self): self.btnnum3_hiSpd.configure(image=self.btnnum3_hiSpd_change_gif) sampler = Sampler() s3 = Sound.from_file(song_name3) s3.stretch_factor = 2 sampler.play(s3) self.btnnum3_hiSpd.configure(image=self.btnnum3_hiSpd_gif)
def song4_lowSpd(self): self.btnnum4_lowSpd.configure(image=self.btnnum4_lowSpd_change_gif) sampler = Sampler() s4 = Sound.from_file(song_name4) s4.stretch_factor = 0.5 sampler.play(s4) self.btnnum4_lowSpd.configure(image=self.btnnum4_lowSpd_gif)
def setUp(self): self.s1 = Sound.from_file(example_audio_file()) freq, dt, sr = 440.0, 10.0, 22050 t = numpy.linspace(0, dt, sr * dt) self.s2 = Sound(numpy.sin(2 * numpy.pi * freq * t), sr) self.sounds = [self.s1, self.s2]
def test_load_sound(self): s1 = Sound.from_file(self.audio_file) y, sr = librosa.load(self.audio_file) s2 = Sound(y, sr) self.assertTrue(numpy.all(s1.y == s2.y)) s3 = Sound(numpy.random.rand(random.randint(1, 100000)), random.choice((88200, 44100, 22050, 11025)))
def setUp(self): self.s1 = Sound.from_file(example_audio_file()) freq, dt, sr = 440.0, 10.0, 22050 t = numpy.linspace(0, dt, sr * dt) self.s2 = Sound(numpy.sin(2 * numpy.pi * freq * t), sr) self.sounds = [self.s1, self.s2, copy.deepcopy(self.s1)] self.sampler = Sampler(backend='dummy')
def pitch_shift(): sampler = Sampler() wav_file = kRecordedWav s1 = Sound.from_file(wav_file) sampler.play(s1) # Add random effects to be interesting while s1.playing: s1.pitch_shift = random.choice( [random.randint(-5, -3), random.randint(15, 20)]) s1.stretch_factor = random.choice([.8, 1.2]) time.sleep(.8)
def song4_origin(self): self.btnnum4_origin.configure(image=self.btnnum4_origin_change_gif) sampler = Sampler() s4 = Sound.from_file(song_name4) sampler.play(s4) self.btnnum4_origin.configure(image=self.btnnum4_origin_gif)
def song4_origin(self): sampler = Sampler() s4 = Sound.from_file(song_name4) sampler.play(s4)
def song1_lowKey(self): sampler = Sampler() s1 = Sound.from_file(song_name1) s1.pitch_shift = -1 sampler.play(s1)
import serial from aupyom import Sampler, Sound from aupyom.util import example_audio_file # start playing sampler = Sampler() audio_file = "/Users/antonis/PycharmProjects/listentoyourheart/Travis Scott - SICKO MODE (Official Audio)-192.mp3" s1 = Sound.from_file(audio_file) sampler.play(s1) # data ser = serial.Serial('/dev/cu.usbmodem14101') first_line = ser.readline() #discard first line while True: try: ser_bytes = ser.readline().decode("utf=8") beat = int(ser_bytes[5:7]) print(beat) factor = (4 * ((beat - 40) / 100)) print(factor) s1.stretch_factor = factor except ValueError: print("") except ZeroDivisionError: print("")
def song4_hiSpd(self): sampler = Sampler() s4 = Sound.from_file(song_name4) s4.stretch_factor = 2 sampler.play(s4)
def song3_origin(self): self.btnnum3_origin.configure(image=self.btnnum3_origin_change_gif) sampler = Sampler() s3 = Sound.from_file(song_name3) sampler.play(s3) self.btnnum3_origin.configure(image=self.btnnum3_origin_gif)
def song2_origin(self): self.btnnum2_origin.configure(image=self.btnnum2_origin_change_gif) sampler = Sampler() s2 = Sound.from_file(song_name2) sampler.play(s2) self.btnnum2_origin.configure(image=self.btnnum2_origin_gif)
def play_sound_only_if_correct_sr(self): sr = random.choice(88200, 44100, 11025) s = Sound.from_file(self.audio_file, sr=sr) with self.assertRaises(): self.sampler.play(s)
def song3_lowKey(self): sampler = Sampler() s3 = Sound.from_file(song_name3) s3.pitch_shift = -1 sampler.play(s3)
def song2_lowSpd(self): sampler = Sampler() s2 = Sound.from_file(song_name2) s2.stretch_factor = 0.5 sampler.play(s2)
def song1_origin(self): self.btnnum1_origin.configure(image=self.btnnum1_origin_change_gif) sampler = Sampler() s1 = Sound.from_file(song_name1) sampler.play(s1) self.btnnum1_origin.configure(image=self.btnnum1_origin_gif)
if __name__ == "__main__": # 0 : up # 1 : right # 2 : down # 3 : left filepath = "mvp.csv" fs = 44100 x, y = get_csv_data(filepath) slopes = find_slopes(x, y) randvar = np.random.normal(0, 1, 100) binned = bin_data(y, 10, .5) pitch_shifts = binned speed = 5 sampler = Sampler() s1 = Sound.from_file("A.wav") xpoint = 0 paused = False key = keyhit.KBHit() while True: print("arrow") if paused == False: arrow = key.getarrow() print("STARTING SAMPLER") while (paused == False): print("while paused is false") sampler.play(s1) since_start = time.clock() for pitch in pitch_shifts[0:]: pausearrow = key.getarrow() if pausearrow == arrow:
def song3_lowSpd(self): sampler = Sampler() s3 = Sound.from_file(song_name3) s3.stretch_factor = 0.5 sampler.play(s3)
def song3_origin(self): sampler = Sampler() s3 = Sound.from_file(song_name3) sampler.play(s3)
def song2_lowKey(self): sampler = Sampler() s2 = Sound.from_file(song_name2) s2.pitch_shift = -1 sampler.play(s2)
def song1_hiSpd(self): sampler = Sampler() s1 = Sound.from_file(song_name1) s1.stretch_factor = 2 sampler.play(s1)
def song1_lowSpd(self): sampler = Sampler() s4 = Sound.from_file(song_name4) s4.stretch_factor = 0.5 sampler.play(s4)
def song4_lowKey(self): sampler = Sampler() s4 = Sound.from_file(song_name4) s4.pitch_shift = -1 sampler.play(s4)