Ejemplo n.º 1
0
def __sound_notification_success(*args):
    HZ = 540
    sound = Triangle(HZ).to_audio_segment(
        duration=100).apply_gain(-20).fade_in(20).fade_out(20)
    sound += AudioSegment.silent(duration=100)
    sound += Triangle(HZ).to_audio_segment(
        duration=100).apply_gain(-20).fade_in(20).fade_out(20)
    display(InvisibleAudio(data=sound.export().read(), autoplay=True))
Ejemplo n.º 2
0
def triangleDot(value, pan, ms=100, factor=1.0, sampleRate=96000, bitDepth=32):
    cNote = 440
    wave = Triangle(cNote * ((value + 0.0001) * 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
Ejemplo n.º 3
0
    def display(self, *args, **kwargs):
        progress_rate = self.n / self.total
        pan = max(min(-1.0 + progress_rate * 2, 1.0), -1.0)

        sound = Triangle(523.23 + progress_rate*523.27).to_audio_segment(duration=100)\
            .apply_gain(-10)\
            .fade_in(20)\
            .fade_out(20)\
            .pan(pan)

        display(InvisibleAudio(data=sound.export().read(), autoplay=True))

        super(tqdm, self).display(*args, **kwargs)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
    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()