Libraryless. Click here for Pure Java version (2503L/16K).
1 | static CloseableItIt<short[]> decodeWAVToMonoSamples_iterator(File wavFile) { |
2 | ret decodeWAVToMonoSamples_iterator(wavFile, 4096); |
3 | } |
4 | |
5 | // windowSize is in seconds |
6 | static CloseableItIt<short[]> decodeWAVToMonoSamples_iterator(File wavFile, double windowSize) ctex { |
7 | WAVDecoder decoder = new(newFileInputStream(wavFile)); |
8 | ret decodeWAVToMonoSamples_iterator(decoder, iround(windowSize*decoder.sampleRate)); |
9 | } |
10 | |
11 | // windowSize is in samples |
12 | static CloseableItIt<short[]> decodeWAVToMonoSamples_iterator(File wavFile, int windowSize) ctex { |
13 | WAVDecoder decoder = new(newFileInputStream(wavFile)); |
14 | ret decodeWAVToMonoSamples_iterator(decoder, windowSize); |
15 | } |
16 | |
17 | static CloseableItIt<short[]> decodeWAVToMonoSamples_iterator(WAVDecoder decoder, int windowSize) ctex { |
18 | ret iteratorFromFunction_f0_autoCloseable(func -> short[] { |
19 | short[] buf = new short[windowSize]; |
20 | int n = decoder.readMonoSamples(buf); |
21 | if (n <= 0) null; |
22 | ret subArray(buf, 0, n); |
23 | }, decoder); |
24 | } |
Began life as a copy of #1019662
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1024592 |
Snippet name: | decodeWAVToMonoSamples_iterator |
Eternal ID of this version: | #1024592/7 |
Text MD5: | bab941dc8c58b3043c7857d70390c619 |
Transpilation MD5: | a10338d4eec7e50339d4b56888c96d08 |
Author: | stefan |
Category: | javax / sound |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-03 12:51:05 |
Source code size: | 999 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 267 / 365 |
Version history: | 6 change(s) |
Referenced in: | [show references] |