コード例 #1
0
ファイル: test_time_stretch.py プロジェクト: y-hira/aupyom
    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]
コード例 #2
0
ファイル: test_sound_loading.py プロジェクト: y-hira/aupyom
    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)))
コード例 #3
0
    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')
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
 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)
コード例 #9
0
 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)
コード例 #10
0
 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)
コード例 #11
0
 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)
コード例 #12
0
    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]
コード例 #13
0
    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)))
コード例 #14
0
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)
コード例 #15
0
 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)
コード例 #16
0
 def song4_origin(self):
     sampler = Sampler()
     s4 = Sound.from_file(song_name4)
     sampler.play(s4)
コード例 #17
0
 def song1_lowKey(self):
     sampler = Sampler()
     s1 = Sound.from_file(song_name1)
     s1.pitch_shift = -1
     sampler.play(s1)
コード例 #18
0
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("")
コード例 #19
0
 def song4_hiSpd(self):
     sampler = Sampler()
     s4 = Sound.from_file(song_name4)
     s4.stretch_factor = 2
     sampler.play(s4)
コード例 #20
0
 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)
コード例 #21
0
 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)
コード例 #22
0
ファイル: test_sound_loading.py プロジェクト: y-hira/aupyom
    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)
コード例 #23
0
 def song3_lowKey(self):
     sampler = Sampler()
     s3 = Sound.from_file(song_name3)
     s3.pitch_shift = -1
     sampler.play(s3)
コード例 #24
0
 def song2_lowSpd(self):
     sampler = Sampler()
     s2 = Sound.from_file(song_name2)
     s2.stretch_factor = 0.5
     sampler.play(s2)
コード例 #25
0
 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)
コード例 #26
0
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:
コード例 #27
0
 def song3_lowSpd(self):
     sampler = Sampler()
     s3 = Sound.from_file(song_name3)
     s3.stretch_factor = 0.5
     sampler.play(s3)
コード例 #28
0
 def song3_origin(self):
     sampler = Sampler()
     s3 = Sound.from_file(song_name3)
     sampler.play(s3)
コード例 #29
0
 def song2_lowKey(self):
     sampler = Sampler()
     s2 = Sound.from_file(song_name2)
     s2.pitch_shift = -1
     sampler.play(s2)
コード例 #30
0
    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)
コード例 #31
0
 def song1_hiSpd(self):
     sampler = Sampler()
     s1 = Sound.from_file(song_name1)
     s1.stretch_factor = 2
     sampler.play(s1)
コード例 #32
0
 def song1_lowSpd(self):
     sampler = Sampler()
     s4 = Sound.from_file(song_name4)
     s4.stretch_factor = 0.5
     sampler.play(s4)
コード例 #33
0
 def song4_lowKey(self):
     sampler = Sampler()
     s4 = Sound.from_file(song_name4)
     s4.pitch_shift = -1
     sampler.play(s4)