Skip to content

Commit f306420

Browse files
committed
pop
1 parent 8deedf5 commit f306420

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from io import BytesIO
2727
import librosa
2828
import soundfile as sf
29-
from pydub.effects import speedup
3029
from pydub.playback import play
3130
import sounddevice as sd
3231
#pynanosvg
@@ -547,6 +546,11 @@ def constrain(val, min_val, max_val):
547546
musicintrofilepath = ""
548547
pymusictype = ""
549548

549+
def pitch_shift(sound, semitones):
550+
new_sample_rate = int(sound.frame_rate * (2.0 ** (semitones / 12.0)))
551+
shifted = sound._spawn(sound.raw_data, overrides={'frame_rate': new_sample_rate})
552+
return shifted.set_frame_rate(sound.frame_rate)
553+
550554
def PlayMusic(musNum):
551555
pygame.mixer.music.stop()
552556
global pygamemixermusic, musicfilepath, musicintrofilepath
@@ -582,9 +586,13 @@ def PlayMusic(musNum):
582586
musicfilepath = "./assets/audio/INOSSI - Got you-loop 44100.wav"
583587
musicintrofilepath = "./assets/audio/INOSSI - Got you-start 44100.wav"
584588
# Load audio file
589+
pygame.mixer.music.load(musicintrofilepath)
585590
music1 = AudioSegment.from_file(musicintrofilepath)
586591
music2 = AudioSegment.from_file(musicfilepath)
587-
592+
593+
shifted_sound1 = pitch_shift(music1, 3) # 4 semitones up
594+
shifted_sound2 = pitch_shift(music2, 3) # 4 semitones up
595+
play(shifted_sound1)
588596
pygame.mixer.music.load(musicintrofilepath)
589597
pygame.mixer.music.set_volume(Decimal(pygamemixermusic))
590598
pygame.mixer.music.set_volume(min(1.0, pygame.mixer.music.get_volume() * 1.1))

save/SaveData.pickle

30 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)