This might continue over a number of blocks.
| 852 | |
| 853 | //This might continue over a number of blocks. |
| 854 | double VoiceKey::TestEnergy ( |
| 855 | const WaveChannel & t, sampleCount start, sampleCount len) |
| 856 | { |
| 857 | |
| 858 | double sum = 1; |
| 859 | auto s = start; //Keep track of start |
| 860 | auto originalLen = len; //Keep track of the length of block to process (its not the length of t) |
| 861 | const auto blockSize = limitSampleBufferSize( |
| 862 | t.GetMaxBlockSize(), len); //Determine size of sampling buffer |
| 863 | Floats buffer{ blockSize }; //Get a sampling buffer |
| 864 | |
| 865 | while(len > 0) |
| 866 | { |
| 867 | //Figure out how much to grab |
| 868 | auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len ); |
| 869 | |
| 870 | t.GetFloats(buffer.get(), s,block); //grab the block; |
| 871 | |
| 872 | //Now, go through the block and calculate energy |
| 873 | for(decltype(block) i = 0; i< block; i++) |
| 874 | { |
| 875 | sum += buffer[i]*buffer[i]; |
| 876 | } |
| 877 | |
| 878 | len -= block; |
| 879 | s += block; |
| 880 | } |
| 881 | |
| 882 | return sum / originalLen.as_double(); |
| 883 | } |
| 884 | |
| 885 | |
| 886 | //This will update RMSE by adding one element and subtracting another |
nothing calls this directly
no test coverage detected