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

Add a method to get raw audio sample data #2632

Open
4321ba opened this issue Apr 22, 2021 · 2 comments
Open

Add a method to get raw audio sample data #2632

4321ba opened this issue Apr 22, 2021 · 2 comments

Comments

@4321ba
Copy link

4321ba commented Apr 22, 2021

Describe the project you are working on

An interactive wave to midi editor / music transcription software called MeloMIDI

Describe the problem or limitation you are having in your project

I needed to get the raw audio data (samples and sample rate) at runtime from the user's audio file, which is not possible with GDScript. I not only need it for playback (for which I used GDScriptAudioImport), but to process the audio non-realtime.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It would help if the decoding could be done with the editor's built-in decoders (wav, ogg and mp3).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

AudioStream (or AudioStreamMP3, AudioStreamOGGVorbis and AudioStreamSample) could have a method to get the samples as a PoolByteArray (and the sample rate as an int) (in case the decoders already have the functionality and it's just not exposed). Channels are a question.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Well kindof, you can use a 3rd party c++ library, like I used libnyquist, it just seems a little bit wasteful to have 2 decoders for all the formats. I'm alright with it though, I need gdnative for an fft library anyway (the built-in spectrum analyzer is wayyy too imprecise for my niche use-case, and it's realtime too so the user would need to listen to the whole thing before anything else).
I don't know though if anyone needed this who doesn't use gdnative, I just thought I'd share my use case. It's fine to close this too if there's no way any other people found this useful :D.

Is there a reason why this should be core and not an add-on in the asset library?

It would affect core classes.

@Calinou Calinou changed the title Get raw audio samples from GDScript Add a method to get raw audio sample data Oct 25, 2021
@awltux
Copy link

awltux commented Aug 11, 2023

I'm interested in this too. I wondered if there were any thoughts on how i could implement it? I get the impression that a specialised AudioStreamPlay module might do the trick, but that might also integrate it with the AudioServer. I'm also not clear whether it could be forced to play in real time rather than sample time. (Noob to code base).

@Eclextic
Copy link

Eclextic commented Sep 5, 2024

No, honestly I think anyone could easily just expose the byte array of these AudioStream classes…

Shouldn’t be really hard if we already store them for use…

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

No branches or pull requests

4 participants