MCPcopy Create free account
hub / github.com/audacity/audacity / TestEnergy

Method TestEnergy

src/VoiceKey.cpp:854–883  ·  view source on GitHub ↗

This might continue over a number of blocks.

Source from the content-addressed store, hash-verified

852
853//This might continue over a number of blocks.
854double 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

Callers

nothing calls this directly

Calls 5

limitSampleBufferSizeFunction · 0.85
GetMaxBlockSizeMethod · 0.45
GetBestBlockSizeMethod · 0.45
GetFloatsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected