Repository navigation
Audio from streams, one-shots, armed jumps and fades on the audio thread
4.0.13 lets you play audio straight from a Stream, with no temporary file, and adds one-shots that clean up after themselves. Jumps and stops can be armed so that every track lands on the same frame. Fades now run on the audio thread instead of a UI timer. Tracks also stay in step after a seek or a start.
Streams in, nothing on disk
new FileSource(stream, leaveOpen)accepts any readable stream: an app asset, an embedded resource or a download. The format is detected from the content. The stream is read to its end once, so it does not have to be seekable, and Android's forward-only asset streams work. Unless you passleaveOpen: true, the stream is disposed before the constructor returns.- Decoding happens in memory. The Rust decoder opens either a path or encoded bytes held in a shared buffer, so the temp-file decoder is gone. A source built from a stream behaves like one built from a file, standalone or on a mixer, in rust-native mode too: it seeks, loops, follows tempo and pitch, and
GetPeaks/GetFloatAudioDatawork on it. EncodedAudiowraps the bytes on the managed side.StreamingAudioDecoder,MultiTrackSession.AddFileTrackandAudioDecoderFactory.Create(Stream)accept it.- The library itself has no UI dependency. Avalonia's
AssetLoader, MAUI'sOpenAppPackageFileAsync, Android'sAssets.OpenandGetManifestResourceStreamall hand it the same kind of stream.
One-shots
mixer.PlayOneShot(samples | stream | path, volume)plays a sound once. The mixer takes it off the bus and disposes it when it ends, so there is nothing for you to clean up. The returned id lets you cut it short withRemoveSource(id).mixer.LoadSamples(stream | path)decodes a sound once into afloat[]at the mixer's format. Use it for a sound you fire often; overlapping copies are fine.- A one-shot does not follow the transport:
Stop,PauseandSeekon the mixer leave it ringing.ActiveOneShotscounts the one-shots still sounding.ClearSources()andDispose()take the pending ones with them. - Behind this,
SampleSource.FollowsTransport = falsetakes a source out of the mixer's start, pause and stop. A pad can wait on the mixer and sound whether the song is playing, paused or stopped.
Armed jumps and stops
AudioMixer.ArmJump(atSongSeconds, toSongSeconds)arms a jump ahead of time: a loop back, a skipped section or a queued jump. Every track carries it out on the exact frame with a 5 ms equal-power crossfade. There is no seek, so there is no gap and effect tails ring on.- A file track takes the jump on a second stream of itself, opened and positioned ahead of time. The decoder that is playing is never seeked, and a jump at 90 % tempo leaves no gap.
AudioMixer.ArmStop(atSongSeconds)fades every track out over 5 ms on a song frame.JumpTakenreports when every armed track has taken the jump. If its moment passed (Late), you seek there yourself. Positions are song (content) seconds, so a jump stays on its marker after a tempo change.
Fades on the audio thread
- Fade in, fade out and the dip used to be ramps written by a 50 Hz UI timer. The engine now ramps frame by frame, in dB, on a separate multiplier that leaves the volume you set unchanged.
- On a track the fade runs after the effects, so a reverb tail fades with the dry signal and the meters show what you hear.
- New:
FadeMaster,FadeMasterAsync(returns once the end of the ramp has been rendered),IsMasterFadeDone,MasterFadeLevel,FadeSource,IsSourceFadeDone, andAudioTrack.FadeTo/MultiTrackSession.FadeMasteron the native side.
Tracks stay together
- After a seek or a start, the native mixer holds every file track silent until each one has audio at the new position, then releases them all on the same block. Before this, a slow prefetch could leave a track a block behind until the next seek. Live inputs stay outside this hold, so monitoring never drops out.
- A file source counts as ready after 8192 fresh frames, and every source is checked on every block. A seek on 30 tracks no longer leaves a 320 ms hole.
StartPreparedSources(startPosition, preRoll)holds every track silent for the pre-roll, sample-accurately, so a count-in no longer depends on a UI timer.
Reliability
- A full mixer command queue now raises
CommandQueueFullException(AudioEngineErrorCode.CommandQueueFull). Before, it came back as an internal error you could only recognise by its message. - If the native attach fails,
AddSource/AddSourcePreparedtake the source back off the mixer.AddSourcesPreparedadds a whole line-up and waits out a full queue for up to a second. WhenEffectReleasedAsyncreturns once a removed effect is off every chain, so a VST3 plugin can be disposed safely, without a fixed delay. A removal that a full queue refused is retried instead of dropped.OutputLatencyFramesno longer reads 0 while a native session is playing.
Other
- New example:
Ownaudio.Example.Stream, a console app that plays embedded mp3s as streams, as one-shots and as looping music. - OwnAudioVst 2.1.1.
- Documentation: modernmube.github.io/OwnAudioSharp
Full Changelog: V4.0.12...V4.0.13
Packages (NuGet)
| Package | Version |
|---|---|
OwnAudioSharp |
4.0.13 |
OwnAudioSharp.Basic |
4.0.13 |
OwnAudioSharp.Mobile |
4.0.13 |
OwnAudioSharp.Midi |
4.0.13 |
OwnAudioSharp.Mt3 |
4.0.13 |