1 | /** Computes the RMS volume of a group of audio samples (0 to 1) */ |
2 | static double audio_rmsVolume_shorts(short[] raw) { |
3 | if (empty(raw)) ret 0; |
4 | double sum = 0; |
5 | for (int ii=0; ii<raw.length; ii++) |
6 | sum += raw[ii]; |
7 | double average = sum/raw.length; |
8 | |
9 | double sumMeanSquare = 0d; |
10 | for (int ii=0; ii<raw.length; ii++) |
11 | sumMeanSquare += Math.pow(raw[ii]-average, 2d); |
12 | |
13 | double averageMeanSquare = sumMeanSquare/raw.length; |
14 | double rootMeanSquare = Math.sqrt(averageMeanSquare); |
15 | |
16 | ret rootMeanSquare/Short.MAX_VALUE; |
17 | } |
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: | 194 / 223 |
Referenced in: | [show references] |