Skip to content

way to get i16 input even when it is not supported? #662

Closed

Description

@droundy

There is code to convert from f32 to i16, but I don't see how to write code that needs to work with i16 in a portable way, that uses straight i16 input where available, and otherwise performs a conversion. Perhaps this already exists?

Activity

  1. LastExceed commented on Aug 16, 2026

    @LastExceed
    Collaborator

    I would argue that this is beyond cpal's scope, as it is not something that needs to be abstracted across different backends, but rather something you would build on top of cpal

  2. roderickvd commented on Aug 16, 2026

    @roderickvd
    Member

    I'm not sure which "code to convert from f32 to i16" you mean?

    I used to agree with @LastExceed from the perspective of "cpal abstracts over system APIs". From the perspective of "cpal" as cross-platform abstraction however, this was discussed not so long ago over at Discord:

    I guess we could add a build_output_stream_converting::<T, D, E>() that takes a T of the caller's choosing, and have cpal use default_*_config() internally to determine the device's default sample format and convert to that.

    dasp_sample makes it easy so it wouldn't be hard to add or maintain, just a question of responsibility.

  3. LastExceed commented on Aug 16, 2026

    @LastExceed
    Collaborator

    I'm not sure which "code to convert from f32 to i16" you mean?

    Probably the FromSample / ToSample trait impls

  4. locked and limited conversation to collaborators on Aug 17, 2026
  5. converted this issue into a discussion #1326 on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions