def getSawSound(freq,beat,subdivison, bpm=60): beat_in_mili = (60. / bpm) * 1000. /subdivison *beat saw = Sawtooth(freq) sound = saw.to_audio_segment(beat_in_mili) sound = sound.fade_in(int(beat_in_mili*.05)) sound = sound.fade_out(int(beat_in_mili*.05)) return sound
def generate_notes_r(): track = AudioSegment.empty() for i in range(16): saw = Sawtooth(NOTES.get(NAMES.get(random.randint(1, 8)))) track += saw.to_audio_segment(500, VOLUME) return track
def __sound_notification_error(*args): HZ = 100 sound = Sawtooth(HZ).to_audio_segment( duration=100).apply_gain(-20).fade_in(20).fade_out(20) sound += AudioSegment.silent(duration=100) sound += Sawtooth(HZ).to_audio_segment( duration=100).apply_gain(-20).fade_in(20).fade_out(20) display(InvisibleAudio(data=sound.export().read(), autoplay=True))
def sawtoothDot(value, pan, ms=100, factor=1.0, sampleRate=96000, bitDepth=32): cNote = 440 wave = Sawtooth(cNote * ((value + 0.00001) * factor), sample_rate=sampleRate, bit_depth=bitDepth) output = wave.to_audio_segment(duration=ms) output = output.fade_in(int(ms * 0.2)) output = output.fade_out(int(ms * 0.2)) output = output.pan(pan) return output
def generate_notes(): track = AudioSegment.empty() print("Please enter notes you want to play, separated by a space.") print("Available notes: ") print(NOTES.keys()) notes = input().split(" ") for note in notes: saw = Sawtooth(NOTES.get(note)) track += saw.to_audio_segment(500, VOLUME) return track
def from_generator(self, freq, duration, wavetype): """ Sets the Audio Object's audio segment to be the audio generated by a wave generator. Arguments freq -- the frequency of the wave to be generated (in Hz) (int) duration -- the duration of the wave to be generated (in milliseconds) (int) wavetype -- the type of wave to be generated. A string containing either Sine, Square, Sawtooth, or Triangle (case insenstivie) (str) """ _check_type(wavetype, "wavetype", str) _check_type(freq, "freq", int) _check_type(duration, "duration", int) self._duration = duration if wavetype.upper() == "SINE": wave = Sine(freq) elif wavetype.upper() == "SAWTOOTH": wave = Sawtooth(freq) elif wavetype.upper() == "SQUARE": wave = Square(freq) elif wavetype.upper() == "TRIANGLE": wave = Triangle(freq) else: raise ValueError("Error! Invalid Wavetype \"" + wavetype + "\" passed to from_generator") self._audioseg = wave.to_audio_segment(duration)
def make_tone(self, freq): if self.waveEntry.get() == "Sine": tone = (Sine(freq).to_audio_segment( duration=int(self.durEntry.get())).fade_out( self.slider.get()).fade_in(self.slider2.get())).apply_gain( self.slider3.get()) + self.slider4.get() elif self.waveEntry.get() == "Square": tone = (Square(freq).to_audio_segment( duration=int(self.durEntry.get())).fade_out( self.slider.get()).fade_in(self.slider2.get())).apply_gain( self.slider3.get()) + self.slider4.get() elif self.waveEntry.get() == "Triangle": tone = (Triangle(freq).to_audio_segment( duration=int(self.durEntry.get())).fade_out( self.slider.get()).fade_in(self.slider2.get())).apply_gain( self.slider3.get()) + self.slider4.get() elif self.waveEntry.get() == "Sawtooth": tone = (Sawtooth(freq).to_audio_segment( duration=int(self.durEntry.get())).fade_out( self.slider.get()).fade_in(self.slider2.get())).apply_gain( self.slider3.get()) + self.slider4.get() elif self.waveEntry.get() == "Pulse": tone = (Pulse(freq).to_audio_segment( duration=int(self.durEntry.get())).fade_out( self.slider.get()).fade_in(self.slider2.get())).apply_gain( self.slider3.get()) + self.slider4.get() play(tone)
def test_with_smoke(self): Sine(440).to_audio_segment() Square(440).to_audio_segment() Triangle(440).to_audio_segment() Pulse(440, duty_cycle=0.75).to_audio_segment() Sawtooth(440, duty_cycle=0.75).to_audio_segment() WhiteNoise().to_audio_segment()