faiface / beep

A little package that brings sound to any Go application. Suitable for playback and audio-processing.
MIT License
2.08k stars 151 forks source link

Also send output to a new file vs just speaker #150

Open andrewarrow opened 2 years ago

andrewarrow commented 2 years ago

Hello, I have example from https://github.com/faiface/beep/wiki/Composing-and-controlling

    for {
        fmt.Print("Press [ENTER] to pause/resume. ")
        fmt.Scanln()

        speaker.Lock()
        ctrl.Paused = !ctrl.Paused
        volume.Volume += 0.5
        speedy.SetRatio(speedy.Ratio() + 0.1) // <-- right here
        speaker.Unlock()
    }

working nicely. My question is, can I also send the output to a NEW mp3 file on disk with all the pauses (added silence) and the speed increases as the user controls them? That is they play the original source.mp3 file (say it's 1 minute long) and hit pause as they like, and speed it up, slow it down etc. and the end result is 2 minutes of audio played through the speaker. Can I have that 2 minute of new audio as a new mp3 file?

gilwo commented 2 years ago

theoretically there is no problem doing that. but there is no mp3 Encode support in the beep library at the moment. you can, if you wish, use the wav encode method to write as a wave and later (or offline) to convert to mp3.