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

Asio support for int24 #927

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nico-franco-gomez
Copy link

@nico-franco-gomez nico-franco-gomez commented Nov 13, 2024

The ASIO API supports the sample formats int24 (3 bytes long) in little and big endian variants (see documentation page 33 and 34). Some professional audio interfaces make use of this part of the API. Currently, the ASIO host does not allow for this, so these devices are left unsupported altogether.

This PR introduces support for these sample formats without changing much of the external API. The only change is the fact that the sample format I24 is uncommented. This is a breaking change since the enum has a new member.

Regarding this implementation

Current implementation uses a single function with generics which allows to parse the SampleFormats from/to the ASIO types. Since int24 has no direct representation with rust primitive types, and is in fact represented internally using a i32, this implementation reads/writes bytes directly from/to the ASIO buffers.

ASIO does not support the other sample types such as U24, I48 and U48. Therefore, I decided to implemented a single function for this special case, without refactoring much of the already working one. This part of the ASIO API will likely not change in the future, so I see no benefit in writing a general function to support the aforementioned types.

The existing function could be rewritten completely to support all types (including int24) simultaneously if it would write the raw bytes directly instead of using rust primitive types for every case. It might be somewhat more concise, but it does require refactoring of working code, which in this case, I personally see as a waste of resources.

Examples

Some examples were extended to the use of I24. I honestly never use anything else than ASIO or CoreAudio, so I'm not certain, that everything will just work for the other hosts.

Tests

I did manual tests with a professional audio interface which utilizes ASIO int24 as its default sample type. Both callbacks worked as expected. No unit tests were added here.

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

Successfully merging this pull request may close these issues.

1 participant