Skip to content

FR: Expose PCM_source::GetBitsPerSample() to ReaScript API #1010

Closed

Description

@X-Raym

Hi,

there is currently no efficient way to get bit per sample of an audio file with ReaScript.

The function seems to exists in www.reaper.fm/files/reaper_plugin.h (but I don't know if it works).
Looks for GetBitsPerSample().

It would be nice if we could expose it to ReaScript API, as handling such thing from ReaScript requires quite a lot of code. Here, it will be just one line.

Here was the discussion thread.

Thx !

Activity

  1. added a commit that references this issue on Jun 15, 2018
    9c7226f
  2. cfillion commented on Jun 15, 2018

    @cfillion
    Member

    I also added APIs for getting/setting pcm sources online/offline status. The test build is at https://cfillion.ca/files/sws/pcm-source-api/.

  3. X-Raym commented on Jun 15, 2018

    @X-Raym
    ContributorAuthor

    @cfillion Excellent ! So more handy that the whole lua code I use to have (more than 100lines, with a shell comand etc for v1, then full file parsing for v2 in 20 lines... not just 1 !).

    item = reaper.GetSelectedMediaItem( 0, 0 )
    take = reaper.GetActiveTake( item )
    source =  reaper.GetMediaItemTake_Source( take )
    bit_depth = reaper.CF_GetMediaSourceBitDepth(source)

    I tested with all bit depth avaible by wavefile, seems to work good,
    exept very esoteric one like 4 (IMA ADPCM) and Bits/sample: 2 (cADPCM) which returns simply 16, but I honestly don't know them maybe it is expected (also, it is not on SWS side to fix this). In Media Properties and BWFMetaEdit, they do appears like 4 and 2 bits files though. SO I guess it will be something to fix on cockos side. (and add a note in the doc meanwhile)

    image
    (the 2 and 4 bits return 16 with the function)

    Nice thing is that it do work for mp3 and flac ! I didn't test other formats.

  4. cfillion commented on Jun 16, 2018

    @cfillion
    Member

    exept very esoteric one like 4 (IMA ADPCM) and Bits/sample: 2 (cADPCM) which returns simply 16

    That's odd, considering REAPER correctly identifies those in the Source Properties window.

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