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

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

Closed
X-Raym opened this issue Jun 15, 2018 · 3 comments
Closed

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

X-Raym opened this issue Jun 15, 2018 · 3 comments

Comments

@X-Raym
Copy link
Contributor

@X-Raym X-Raym commented Jun 15, 2018

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 !

@cfillion
Copy link
Collaborator

@cfillion cfillion commented Jun 15, 2018

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/.

@X-Raym
Copy link
Contributor Author

@X-Raym X-Raym commented Jun 15, 2018

@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.

@cfillion
Copy link
Collaborator

@cfillion cfillion commented Jun 16, 2018

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.

@swstim swstim closed this in 9c7226f Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants