Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1009778 // audio_rmsVolume

JavaX fragment (include)

1  
/** Computes the RMS volume of a group of signal sizes ranging from -1 to 1. */
2  
static double audio_rmsVolume(float[] 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  
  return rootMeanSquare;
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009778
Snippet name: audio_rmsVolume
Eternal ID of this version: #1009778/1
Text MD5: e37cae3e6a77ad16bab5b0150284ccdb
Author: stefan
Category: javax / audio
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-16 17:47:32
Source code size: 540 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 444 / 498
Referenced in: [show references]