Recursive AI
oneaudioCookbook

oneaudio cookbook

Short recipes for common oneaudio tasks, each a complete program that was run against version 1.2.1, the device recipes with RecursiveAI.OneAudio.Devices 1.2.1.

Recipes

Decode MP3 in C#Decode MP3 files to float samples or WAV in C# with oneaudio, a managed decoder with no native code: gapless trimming, exact seeking, and MP3 bytes held in memory.Decode Ogg Vorbis in C#Decode Ogg Vorbis files in C# with oneaudio: load or stream the samples, read the comment tags, and play chained Ogg files as one stream.Decode Opus in C#Decode Ogg Opus files in C# with oneaudio, convert them to your app’s sample rate, and decode raw Opus packets from a voice or network stream, with packet-loss concealment.Decode audio from a streamDecode audio in C# from a stream that can’t seek, such as a network response or a pipe, block by block with flat memory, with limits and typed errors for untrusted input.Read audio metadataRead the sample rate, channels, bit depth, duration and tags of WAV, MP3, Ogg Vorbis, Opus and FLAC files in C# with oneaudio, without decoding the audio.Read and write FLAC in C#Decode FLAC files bit-exact in C# with oneaudio, verify the MD5 signature, read the tags, and encode WAV to FLAC at compression levels 0 to 8 with your own tags.Read and write WAV files in C#Read WAV and RF64 files in C# with oneaudio as exact integers or floats, and write 16-bit, 24-bit or 32-bit float WAV, with dither when you reduce the bit depth.Encode Opus in C#Encode WAV, FLAC or MP3 to Ogg Opus in C# with oneaudio, a managed Opus encoder: choose the bitrate and mode, add tags, and encode speech with the VoIP application.Convert audio filesConvert MP3, Ogg Vorbis, Opus, FLAC and WAV files to WAV, FLAC or Ogg Opus in C# with oneaudio, change the sample rate and channels on the way, and convert streams in memory.Resample audio in C#Resample audio in C# with oneaudio, from 44.1 kHz to 48 kHz and back or any ratio up to 64, in one call or as a stream, with three quality levels and no allocation while running.Mix audio filesMix music, voice and sound effects in C# with oneaudio’s real-time mixer: buses, ducking, reverb, pitch, a limiter and loudness meters, rendered to a WAV file or to your own audio output.Measure loudness (LUFS, true peak, LRA)Measure integrated loudness in LUFS, loudness range and true peak in C# with oneaudio’s ITU-R BS.1770-5 and EBU R 128 meter, for a whole file or live, block by block.Normalize loudness to −14 or −23 LUFSNormalize audio loudness in C# with oneaudio: write a copy at −14 LUFS, or −23 LUFS for EBU R 128 broadcast, with a true-peak ceiling, or scale samples in memory.Keep only the codecs you useMake small NativeAOT and trimmed .NET apps with oneaudio: register only the formats you read with an AudioKit, so the other decoders are trimmed away.Play an audio filePlay a WAV, MP3, Ogg or FLAC file on the default sound card in C#, with oneaudio’s mixer and the RecursiveAI.OneAudio.Devices package, and check from the device’s own counters that it played.Record from the microphoneRecord audio from the default microphone in C# and save it as a 16-bit WAV file, with the RecursiveAI.OneAudio.Devices package and oneaudio’s WAV encoder.List audio devicesList the playback and recording devices in C#, find the system defaults, and open a particular device by its id, with the RecursiveAI.OneAudio.Devices package.