/** Computes the RMS volume of a group of audio samples (0 to 1) */ static double audio_rmsVolume_shorts(short[] raw) { if (empty(raw)) ret 0; double sum = 0; for (int ii=0; ii<raw.length; ii++) sum += raw[ii]; double average = sum/raw.length; double sumMeanSquare = 0d; for (int ii=0; ii<raw.length; ii++) sumMeanSquare += Math.pow(raw[ii]-average, 2d); double averageMeanSquare = sumMeanSquare/raw.length; double rootMeanSquare = Math.sqrt(averageMeanSquare); ret rootMeanSquare/Short.MAX_VALUE; }
Began life as a copy of #1009778
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1024577 |
Snippet name: | audio_rmsVolume_shorts |
Eternal ID of this version: | #1024577/1 |
Text MD5: | 921a2a8116ffacf29c0497ccfa37fdd9 |
Author: | stefan |
Category: | javax / audio |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-19 14:11:05 |
Source code size: | 548 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 193 / 222 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |