Uses 1634K of libraries. Click here for Pure Java version (11137L/60K).
1 | !7 |
2 | |
3 | set flag OpusFromStream_debug. |
4 | set flag OggStreamPage_debug. |
5 | |
6 | cm TestOpusFromStream > DynPrintLog {
|
7 | S oggSnippetID = #1400517; |
8 | transient SimulatedPartialInputStream in; |
9 | transient OpusFromStream opusReader; |
10 | transient L<short[]> samples; |
11 | |
12 | // We simulate bytes trickling in with these variables |
13 | switchable int firstChunk = 0; |
14 | switchable int chunkSize = 512; |
15 | |
16 | start-thread {
|
17 | File f = loadLibrary(#1400517); |
18 | printFileInfo(f); |
19 | in = new SimulatedPartialInputStream(bufferedFileInputStream(f, OpusFromStream.bufferSizeNeeded())); |
20 | in.cutOffPoint = firstChunk; |
21 | samples = new L; |
22 | |
23 | temp opusReader = new OpusFromStream(in, 1); |
24 | |
25 | int safety = 0; |
26 | while true {
|
27 | if (safety++ >= 1000) fail("SAFETY");
|
28 | var samples = opusReader.nextSamples(); |
29 | if (samples == null && in.streamEnded()) {
|
30 | print("Stream ended: " + in);
|
31 | break; |
32 | } |
33 | if (samples == null) |
34 | in.cutOffPoint += chunkSize; |
35 | print("samples", samples);
|
36 | addIfNotNull(TestOpusFromStream.this.samples, samples); |
37 | } |
38 | print("Iterations: " + safety);
|
39 | |
40 | File wavFile = programFile("output.wav");
|
41 | multiShortArraysToWAVE(samples, wavFile, format := javaSound_opusMono()); |
42 | printFileInfo(wavFile); |
43 | assertEqualsVerbose(355244L, fileSize(wavFile)); |
44 | |
45 | showGraph(); |
46 | } |
47 | |
48 | void showGraph {
|
49 | var pcm = random(samples); |
50 | if (empty(pcm)) ret; |
51 | print("Chose PCM: " + l(pcm));
|
52 | dm_showImageAs("Decoded Audio Sample", shortArrayToGraph(pcm));
|
53 | } |
54 | } |
Began life as a copy of #1032899
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): bhatertpkbcr, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1032909 |
| Snippet name: | Test OpusFromStream (pure java Opus decoder for streaming audio, OK!) |
| Eternal ID of this version: | #1032909/23 |
| Text MD5: | 7e7ebf919e05615850df65dc79dc5935 |
| Transpilation MD5: | abcd14772ad6eed134091e16cf83ce0c |
| 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 21:57:25 |
| Source code size: | 1578 bytes / 54 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 481 / 856 |
| Version history: | 22 change(s) |
| Referenced in: | [show references] |