Free GO Library for Audio Playback & Capture
Open Source GO Library that allows software developers to Play, Record, Encode, Read & Convert Audio files .
Malgo is a very useful Open Source mini Go audio library that fully supports basic as well as advanced audio processing features. The library can be used on all major platforms and has included many advanced features for playing and capturing audio files. The library is very stable and has no bugs or vulnerabilities. The library can be used on all major platforms such as Windows, Linux, macOS, Android & more.
The Malgo library has included several important features such as audio stream support, playing audio files, capturing data from your default microphone, support for sending more data to the device for playback, encoding input audio bytes to PCM, audio stream support, supports all major codecs, access to camera, and many more. The library is licensed under the Unlicense License, which means anyone is free to copy, modify, publish, use, compile, sell, or distribute this software.
Getting Started with Malgo
TThe recommended way to install Malgo into your project is by using GitHub. Please use the following command for a smooth installation.
Install Malgo from GitHub
go get -u github.com/gen2brain/malgo
Capture Audio Data from Microphone via Go
Capturing an audio file refers to a procedure of reading the microphone & obtaining a signal from outside the computer. A common application of audio capture is recording, such as recording the microphone input to a sound file. The Malgo library provides the capability to capture data from your default microphone until the user presses the enter button. Once the process is complete users can save the captured audio to an external drive in the supported file formats.
Capture Audio via Go API
// Capturing will commence writing the samples to the writer until either the
// writer returns an error, or the context signals done.
func Capture(ctx context.Context, w io.Writer, config StreamConfig) error {
deviceConfig := config.asDeviceConfig()
deviceConfig := config.asDeviceConfig(malgo.Capture)
abortChan := make(chan error)
defer close(abortChan)
aborted := false
@@ -32,5 +32,5 @@ func Capture(ctx context.Context, w io.Writer, config StreamConfig) error {
},
}
return stream(ctx, abortChan, malgo.Capture, deviceConfig, deviceCallbacks)
return stream(ctx, abortChan, deviceConfig, deviceCallbacks)
Playback Sound via Go Library
The open source Malgo library enables software developers to load and playback audio files with just a couple of lines of Go commands. The library also provides full support for controlling multiple sounds at the same time inside Go apps. It is also possible to control a specific sound by assigning a sound ID to it and managing it. To autoplay an audio file the library automatically downloads an entire audio file or preloads it using metadata.
Playback Audio Sound via Go API
// Playback will commence playing the samples provided from the reader until either the
// reader returns an error, or the context signals done.
func Playback(ctx context.Context, r io.Reader, config StreamConfig) error {
deviceConfig := config.asDeviceConfig()
deviceConfig := config.asDeviceConfig(malgo.Playback)
abortChan := make(chan error)
defer close(abortChan)
aborted := false
@@ -38,5 +38,5 @@ func Playback(ctx context.Context, r io.Reader, config StreamConfig) error {
},
}
return stream(ctx, abortChan, malgo.Playback, deviceConfig, deviceCallbacks)
return stream(ctx, abortChan, deviceConfig, deviceCallbacks)
Perform Simple Mixing via Go API
Audio mixing is a very useful process of balancing and editing recorded audio tracks to produce a suitable blend of all the sounds present on a single file. The open source Malgo library provides a useful way to load multiple files and play them all back at the same time. When mixing numerous sounds together, users need to create only a single device (not multiple) and then mix the sounds together.