Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't play mono-channel audio. #2851

Open
NewajShovo opened this issue Jul 19, 2023 · 2 comments
Open

Can't play mono-channel audio. #2851

NewajShovo opened this issue Jul 19, 2023 · 2 comments
Labels

Comments

@NewajShovo
Copy link

NewajShovo commented Jul 19, 2023

macOS Version(s) Used to Build

macOS 13 Ventura

Xcode Version(s)

Xcode 14

Description

Hello everyone,
I was trying to play buffer with mono-channel format audio, but somehow the program is crashing.
Like this,

player = AudioPlayer();
let buffer = arrayBuffer[self.currentBufferIndex]; // holds array of buffer.
try? player.load(buffer: arrayBuffer[self.currentBufferIndex]);
engine.output = player
player.play();
player.completionHandler = playBuffer

Just to be specific the format is like this,

ASBD: {
    mSampleRate: 16000.000000 
    mFormatID: 'lpcm' 
    mFormatFlags: 0xc 
    mBytesPerPacket: 2 
    mFramesPerPacket: 1 
    mBytesPerFrame: 2 
    mChannelsPerFrame: 1 
    mBitsPerChannel: 16 	
} 

It's mandatory for me to play mono-channel audio. Unfortunately, I can't make it.
What do you think can be done?

Crash Logs, Screenshots or Other Attachments (if applicable)

No response

@NewajShovo NewajShovo added the bug label Jul 19, 2023
@NickCulbertson
Copy link
Member

Before try? player.load(buffer: arrayBuffer[self.currentBufferIndex]); try setting the player.file to your audio file. That should update the format of the player.

@NickCulbertson
Copy link
Member

Also try loading the audio file and buffer AFTER setting the engine's output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants