Uses 1634K of libraries. Click here for Pure Java version (11252L/58K).
!7 lib 1400511 // VorbisJava (to unpack ogg file) lib 1400502 // Concentus 1.0 (to decode OPUS audio in ogg file) import org.gagravarr.opus.*; import org.concentus.*; cm TestConcentus > DynSingleFunctionWithPrintLog { S oggSnippetID = #1400517; transient L<short[]> samples; @Override void doIt() ctex { OpusDecoder decoder = new(48000, 1); // decode mono File f = loadLibrary(#1400517); temp OpusFile opusFile = new(f); samples = new L; short[] pcm = new[5760]; // max opus frame size (mono) OpusAudioData data; while ((data = opusFile.getNextAudioPacket()) != null) { byte[] bytes = data.getData(); if (empty(bytes)) continue; print("Got compressed audio data: " + l(bytes)); int nSamples = decoder.decode(bytes, 0, l(bytes), pcm, 0, l(pcm), false); print("Got " + nSamples(nSamples)); samples.add(cloneSubShortArray(pcm, 0, nSamples)); } print("Done"); File wavFile = programFile("output.wav"); multiShortArraysToWAVE(samples, wavFile, format := javaSound_opusMono()); printFileInfo(wavFile); showGraph(); } void showGraph { var pcm = random(samples); print("Chose PCM: " + l(pcm)); dm_showImageAs("Decoded Audio Sample", shortArrayToGraph(pcm)); } }
Began life as a copy of #1032896
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): bhatertpkbcr, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032899 |
Snippet name: | Test Concentus (pure java Opus decoder) for decoding Opus stream (OK!) |
Eternal ID of this version: | #1032899/20 |
Text MD5: | 25472a64ab7b23cce418957270721e2a |
Transpilation MD5: | a088b4f65dd4baabd5fd0f77b21eb503 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-10 17:52:48 |
Source code size: | 1351 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 385 / 555 |
Version history: | 19 change(s) |
Referenced in: | #1032909 - Test OpusFromStream (pure java Opus decoder for streaming audio, OK!) |