Uses 521K of libraries. Click here for Pure Java version (18864L/120K).
1 | srecord FrequencyImageFromURL(S url) { |
2 | // all broken?! |
3 | //S url = "https://gaz.ai/dl/audiostreams/gigsauntppvwjyrq.ogg"; |
4 | //S url = "https://gaz.ai/dl/audiostreams/zgmyptzpqlvafoyz.ogg"; |
5 | //S url = "https://gaz.ai/dl/audiostreams/jlokvemsxqhuaups.ogg"; |
6 | |
7 | *() { url = "https://gaz.ai/dl/audiostreams/bjfxzzpdtuhxewdx.ogg"; } |
8 | |
9 | BWImage image; |
10 | |
11 | run { |
12 | temp var opus = new DecodeOpusStream(url); |
13 | opus.minBytesPreloaded = 65536*2; |
14 | temp var samples = opus!; |
15 | opus.machine.init(); |
16 | opus.machine.opusDecoder.printResets = true; |
17 | var querySound = SampleIteratorToQuerySound(1, samples); |
18 | |
19 | new PianoSampler2 sampler; |
20 | //sampler.debug = true; |
21 | sampler.frequencies = intersperseHalfTones(sampler.frequencies); |
22 | sampler.loadSound(querySound, 1); |
23 | sampler.fixedFactor = 5e-4; |
24 | |
25 | var windowSeconds = .05; |
26 | var windowSamples = windowSeconds*sampler.sampleRate; |
27 | printVars(+windowSeconds, +windowSamples); |
28 | |
29 | var relativeWindowSpeed = .5; |
30 | |
31 | int peekSize = iceil(max(windowSamples, sampler.minWindowSizeForBase())*2); |
32 | |
33 | var totalSeconds = 5; |
34 | var startAtSeconds = 0; |
35 | |
36 | var endAtSample = (startAtSeconds+totalSeconds)*sampler.sampleRate; |
37 | |
38 | var seconds = doubleRangeWithLength(startAtSeconds, windowSeconds); |
39 | DoubleRange sampleRange = scaleDoubleRange(seconds, sampler.sampleRate); |
40 | |
41 | // make initial window |
42 | print(+peekSize); |
43 | sampler.makeWindowAround(sampleRange.start, peekSize); |
44 | printVars(+seconds, +sampleRange, bounds := sampler.bounds()); |
45 | |
46 | new L<MakesBufferedImage> images; |
47 | |
48 | int safety = 0; |
49 | while ping (sampleRange.end <= endAtSample && safety++ <= 1000) { |
50 | //print(+sampleRange); |
51 | images.add(sampler.imageColumn(sampler.measureWindow(sampleRange))); |
52 | sampleRange = shiftDoubleRange(sampleRange, windowSamples*relativeWindowSpeed); |
53 | } |
54 | |
55 | image = mergeBWImagesHorizontally(map toBWImage(images), spacing := 0); |
56 | print(nSamples := opus.samplesSeen()); |
57 | print(sampler.stats()); |
58 | } |
59 | |
60 | void showImage { |
61 | dm_showPixelatedImage(image); |
62 | } |
63 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033048 |
Snippet name: | FrequencyImageFromURL |
Eternal ID of this version: | #1033048/8 |
Text MD5: | 4b7be0a4ca19d4fbcb69b3e06c4c1546 |
Transpilation MD5: | 28cf7516c67e6fb6ba75a2ca39b07392 |
Author: | stefan |
Category: | javax / audio analysis |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-11 19:15:15 |
Source code size: | 2162 bytes / 63 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 177 / 295 |
Version history: | 7 change(s) |
Referenced in: | [show references] |