Common interface for audio blocks

This commit is contained in:
Alexander Shabarshov 2026-08-15 08:52:29 +01:00
parent d8e1317a74
commit 4c8d4d2ed9
6 changed files with 31 additions and 11 deletions

View File

@ -33,6 +33,8 @@
<PropertyGroup> <PropertyGroup>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<BuildNumber>0</BuildNumber>
<SourceRevisionId>0000</SourceRevisionId>
<InformationalVersion>$(Version).$(BuildNumber)+$(SourceRevisionId)</InformationalVersion> <InformationalVersion>$(Version).$(BuildNumber)+$(SourceRevisionId)</InformationalVersion>
<AssemblyVersion>$(Version)</AssemblyVersion> <AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version).$(BuildNumber)</FileVersion> <FileVersion>$(Version).$(BuildNumber)</FileVersion>

View File

@ -115,7 +115,7 @@ public sealed class RubberBandTimeStretchEngine : ITimeStretchEngine, IAsyncDisp
return Task.CompletedTask; return Task.CompletedTask;
try try
{ {
proc.Stdin.Flush(); proc.Stdin?.Flush();
} }
catch (System.ObjectDisposedException) catch (System.ObjectDisposedException)
{ {

View File

@ -2,7 +2,7 @@ using AudioCore.Impl;
namespace AudioCore.Models; namespace AudioCore.Models;
public readonly struct AudioBlock : IDisposable public readonly struct AudioBlock : IAudioBlock, IDisposable
{ {
public AudioBuffer<float> Buffer { get; } public AudioBuffer<float> Buffer { get; }
public int SampleRate { get; } public int SampleRate { get; }

View File

@ -0,0 +1,14 @@
using AudioCore.Impl;
namespace AudioCore.Models;
public interface IAudioBlock : IDisposable
{
AudioBuffer<float> Buffer { get; }
int SampleRate { get; }
int Channels { get; }
long Position { get; }
int Frames { get; }
int Length { get; }
Span<float> Span { get; }
}

View File

@ -2,7 +2,7 @@ using AudioCore.Impl;
namespace AudioCore.Models; namespace AudioCore.Models;
public readonly struct MixedAudioBlock : IDisposable public readonly struct MixedAudioBlock : IAudioBlock, IDisposable
{ {
public AudioBuffer<float> Buffer { get; } public AudioBuffer<float> Buffer { get; }
public int Frames { get; } public int Frames { get; }
@ -10,6 +10,8 @@ public readonly struct MixedAudioBlock : IDisposable
public int SampleRate { get; } public int SampleRate { get; }
public long Position { get; } public long Position { get; }
public Span<float> Span => Buffer.Span;
public int Length => Buffer.Length;
public MixedAudioBlock(AudioBuffer<float> buffer, int frames, int channels, int sampleRate, long samplePosition) public MixedAudioBlock(AudioBuffer<float> buffer, int frames, int channels, int sampleRate, long samplePosition)
{ {
Buffer = buffer; Buffer = buffer;

View File

@ -2,7 +2,7 @@ using AudioCore.Impl;
namespace AudioCore.Models; namespace AudioCore.Models;
public readonly struct TimeStretchedAudioBlock : IDisposable public readonly struct TimeStretchedAudioBlock : IAudioBlock, IDisposable
{ {
public AudioBuffer<float> Buffer { get; } public AudioBuffer<float> Buffer { get; }
public int Frames { get; } public int Frames { get; }
@ -10,6 +10,8 @@ public readonly struct TimeStretchedAudioBlock : IDisposable
public int SampleRate { get; } public int SampleRate { get; }
public long Position { get; } public long Position { get; }
public Span<float> Span => Buffer.Span;
public int Length => Buffer.Length;
public TimeStretchedAudioBlock(AudioBuffer<float> buffer, int frames, int channels, int sampleRate, long position) public TimeStretchedAudioBlock(AudioBuffer<float> buffer, int frames, int channels, int sampleRate, long position)
{ {
Buffer = buffer; Buffer = buffer;