Uses 911K of libraries. Click here for Pure Java version (5941L/30K).
!7 cmodule AudioClip > DynSCP { File audioFile; double windowSize = 0.01; // seconds transient JAmplitudeGraph graph; transient float[] volumeProfile; transient short[] fullAudio; // stereo/44.1 KHz start { afterVisualize2(r updateGraph); graph = swingNu JAmplitudeGraph(); } void updateGraph enter { if (!isFile(audioFile)) ret with setComponent(jcenteredbutton("Open audio file...", rThread openFile)); setComponent(northCenterAndSouthWithMargin( jCenteredSection("File", dm_centeredLabel audioFile()), jCenteredSection("Volume Profile", graph), withMargin(jrightalignedbuttons( "Open...", rThread openFile, "Play", rThread play, "Normalize", rThread normalize )))); if (volumeProfile == null) volumeProfile = decodeWAVToMonoSamples_floatVolumeProfile(audioFile, windowSize); graph?.setValues(volumeProfile); } void updateProfile enter { volumeProfile = null; updateGraph(); } void openFile enter { File f = showFileChooser(); if (f != null) loadFile(f); } void loadFile(File f) { setFields(audioFile := f, fullAudio := null); updateProfile(); } void loadFullAudio { if (!isFile(audioFile)) ret; fullAudio = convertSampleRate_stereoShortArray_simple( decodeWAVToStereoSamples(audioFile), wavSampleRate(audioFile), sampleRate()); } void play enter { if (fullAudio == null) loadFullAudio(); dm_addShortArraySoundSource(fullAudio); } void normalize enter { loadFullAudio(); fullAudio = normalizeShortArray(fullAudio); makeVolumeProfileFromMemory(); } void makeVolumeProfileFromMemory enter { volumeProfile = floatVolumeProfileFromStereoShortArray(fullAudio, windowSize, sampleRate()); updateGraph(); } float sampleRate() { ret cdSampleRate(); } }
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: | #1026942 |
Snippet name: | Audio Clip [dev.] |
Eternal ID of this version: | #1026942/14 |
Text MD5: | e96af6aa08b8478c06e3f9f200d14fd9 |
Transpilation MD5: | 51fdc11d7fdb4c898656bcc968390fb1 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-03 14:11:14 |
Source code size: | 1961 bytes / 72 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 286 / 1526 |
Version history: | 13 change(s) |
Referenced in: | -