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_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 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 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 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 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 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 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): sampler = Sampler() s2 = Sound.from_file(song_name2) sampler.play(s2)
def song3_origin(self): sampler = Sampler() s3 = Sound.from_file(song_name3) sampler.play(s3)
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 song4_origin(self): sampler = Sampler() s4 = Sound.from_file(song_name4) sampler.play(s4)
def song2_lowSpd(self): sampler = Sampler() s2 = Sound.from_file(song_name2) s2.stretch_factor = 0.5 sampler.play(s2)
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)
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()
def song1_hiSpd(self): sampler = Sampler() s1 = Sound.from_file(song_name1) s1.stretch_factor = 2 sampler.play(s1)
def song4_lowKey(self): sampler = Sampler() s4 = Sound.from_file(song_name4) s4.pitch_shift = -1 sampler.play(s4)
def song3_lowSpd(self): sampler = Sampler() s3 = Sound.from_file(song_name3) s3.stretch_factor = 0.5 sampler.play(s3)
def song3_lowKey(self): sampler = Sampler() s3 = Sound.from_file(song_name3) s3.pitch_shift = -1 sampler.play(s3)
def song1_origin(self): sampler = Sampler() s1 = Sound.from_file(song_name1) sampler.play(s1)
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)
def choose_song(self): default_dir = r"D://USER//desktop" # 设置默认打开目录 song_name = fdl.askopenfilename(title=u"选择文件", initialdir=(os.path.expanduser(default_dir))) sampler = Sampler() s1 = Sound.from_file(song_name) sampler.play(s1)
def song1_lowKey(self): sampler = Sampler() s1 = Sound.from_file(song_name1) s1.pitch_shift = -1 sampler.play(s1)
def song4_hiSpd(self): sampler = Sampler() s4 = Sound.from_file(song_name4) s4.stretch_factor = 2 sampler.play(s4)
def song2_lowKey(self): sampler = Sampler() s2 = Sound.from_file(song_name2) s2.pitch_shift = -1 sampler.play(s2)
def song1_lowSpd(self): sampler = Sampler() s4 = Sound.from_file(song_name4) s4.stretch_factor = 0.5 sampler.play(s4)
def __init__(self, files): self.sampler = Sampler(44100) self._sounds = [] for i in files: self.load(i)