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

'Sound' package likey has no way to set sample format #30

Open
sergstesh opened this issue Dec 12, 2024 · 5 comments
Open

'Sound' package likey has no way to set sample format #30

sergstesh opened this issue Dec 12, 2024 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@sergstesh
Copy link

Looking into PortAudio documentation, e.g. at https://files.portaudio.com/docs/v19-doxydocs-dev/portaudio_8h.html#a4582d93c2c2e60e12be3d74c5fe00b , which describes 'PaSampleFormat' type, I see that there is a number of sample formats supported.

Also in https://files.portaudio.com/docs/v19-doxydocs-dev/portaudio_8h_source.html I see on line #498 '#define paCustomFormat ((PaSampleFormat) 0x00010000)' . I in practice specifically need S24_3LE for the capture stream of CX31993 because it's the only 24 bit format the ADC supports.

Looking into https://jefffessler.github.io/Sound.jl/stable/methods/#Methods-list I don't see a way to set sample format.

Am I missing something ?

For that matter, looking into https://github.com/JuliaAudio/PortAudio.jl I am not sure it implements setting sample format - I mean number of bits per sample and how the bits are packed in a sample - again, I particularly need S24_3LE.

At the moment I've implemented my code the Linux-only way using 'aplay' and 'arecord' - the two utilities allow me to set whatever sample format supported by the card. I would rather prefer to implement my code cross=platform way.

@JeffFessler
Copy link
Owner

The input signal to the sound function is x::AbstractArray which is quite general.
If your data is of that type then Sound can accept it.
That input is simply passed to PortAudio; if you get an error there then you should post an issue in that repo.
My guess is you will need to go even lower and work with https://github.com/JuliaAudio/SampledSignals.jl

@sergstesh
Copy link
Author

My guess is you will need to go even lower and work with https://github.com/JuliaAudio/SampledSignals.jl

I visited the link before opening this issue and didn't find what I was looking for. I.e. IMO nothing that is stuff like S24_3LE.

Am I missing something ?

@sergstesh
Copy link
Author

The input signal to the sound function is x::AbstractArray which is quite general.

I do not understand whether the quoted statement is relevant for the reported issue.

If I understand you correctly, the quoted statement is about the following https://jefffessler.github.io/Sound.jl/stable/methods/#Sound.sound :

Play monophonic audio signal x at sampling rate S samples per second through default audio output device using the PortAudio package. Caller must specify S unless a framerate method is defined for x.

First of all, I am at the moment interested in specifying capture format (pay attention to "ADC" in my opening statement - which is not DAC) rather than in playback format.

@JeffFessler
Copy link
Owner

Ah sorry, I overlooked the "ADC" focus.
The only input-related function here is record https://github.com/JeffFessler/Sound.jl/blob/main/src/record.jl
And that function in turn simply calls PortAudio's read function so I think you'll have to look there.
TBH, Sound was designed primarily for DAC in a course setting, and ADC is just a small add-on.
I welcome PRs but I won't have time to work on enhancing record myself.

@sergstesh
Copy link
Author

Ah sorry, I overlooked the "ADC" focus. The only input-related function here is record https://github.com/JeffFessler/Sound.jl/blob/main/src/record.jl And that function in turn simply calls PortAudio's read function so I think you'll have to look there. TBH, Sound was designed primarily for DAC in a course setting, and ADC is just a small add-on. I welcome PRs but I won't have time to work on enhancing record myself.

Then I suggest to update the package documentation to state there is no way to explicitly set sample format the way PortAudio "C" library allows to do it.

@JeffFessler JeffFessler added the help wanted Extra attention is needed label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants