Skip to content

Recorder doesn’t work for SampleFormat.S16 #61

Open
@krishnavsr

Description

@krishnavsr

Requirements

  • I have searched the existing issues to ensure this bug has not already been reported.
  • I have provided a clear and concise description of the bug.
  • I have provided detailed steps to reproduce the bug.
  • I have included a minimal reproducible example (MRE) if applicable.
  • I have provided error messages and stack traces if applicable.
  • I have completed the environment information.

1. Describe the Bug

When I tried to use Recorder with SampleFormat.S16 , sample rate 16KHz and channels 1

Using the SoundFlow.Samples.SimplePlayer sample and option 3. Record and playback audio

I hear back garbled audio. Based on my analysis of the code I think the source of the problem is AudioProcessingCallback always sends Span<float> for all sample formats. But for SampleFormat.S16 it should be sending Span<short>

Is there a conversion that needs to be done from Span<float> to Span<short>? It should work for the selected SampleFormat without any post processing.

2. Steps to Reproduce

Step 1:- Run SoundFlow.Samples.SimplePlayer sample and select option 3. Record and playback audio

Recording and Playback works fine

Step 2:- Change the SampleFormat.F32 to SampleFormat.S16, build and run then choose option 3

Recording and Playback does not work

3. Expected Behavior

It should work the same for different SampleFormats that are supported

4. Current Behavior

It plays back noise with SampleFormat.S16

5. Minimal Reproducible Example (MRE)

AudioProcessCallback(Span\<float\> in AudioEngine.cs

6. Error Messages and Stack Trace (if applicable)

SoundFlow Version

3c7d8d2

.NET Version

net8.0

Operating System

macOS Sonoma 14.5

Architecture

ARM64

Audio Backend Used (if known)

No response

Specific Audio Hardware (if relevant)

No response

8. Affected Components/Modules (if known)

No response

9. Impact

incorrect audio output

10. Possible Workaround (if known)

No response

11. Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingin-progressThis issue is actively being worked on; development is currently in progress.

    Projects

    Status

    In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions