| 893 | |
| 894 | |
| 895 | double VoiceKey::TestSignChanges( |
| 896 | const WaveChannel & t, sampleCount start, sampleCount len) |
| 897 | { |
| 898 | |
| 899 | |
| 900 | auto s = start; //Keep track of start |
| 901 | auto originalLen = len; //Keep track of the length of block to process (its not the length of t) |
| 902 | const auto blockSize = limitSampleBufferSize( |
| 903 | t.GetMaxBlockSize(), len); //Determine size of sampling buffer |
| 904 | unsigned long signchanges = 1; |
| 905 | int currentsign=0; |
| 906 | |
| 907 | Floats buffer{ blockSize }; //Get a sampling buffer |
| 908 | |
| 909 | while(len > 0) { |
| 910 | //Figure out how much to grab |
| 911 | auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len ); |
| 912 | |
| 913 | t.GetFloats(buffer.get(), s, block); //grab the block; |
| 914 | |
| 915 | if (len == originalLen) |
| 916 | { |
| 917 | //The first time through, set stuff up special. |
| 918 | currentsign = sgn(buffer[0]); |
| 919 | } |
| 920 | |
| 921 | //Now, go through the block and calculate zero crossings |
| 922 | |
| 923 | for(decltype(block) i = 0; i< block; i++) |
| 924 | { |
| 925 | if( sgn(buffer[i]) != currentsign) |
| 926 | { |
| 927 | currentsign = sgn(buffer[i]); |
| 928 | signchanges++; |
| 929 | } |
| 930 | |
| 931 | } |
| 932 | len -= block; |
| 933 | s += block; |
| 934 | } |
| 935 | return (double)signchanges / originalLen.as_double(); |
| 936 | } |
| 937 | |
| 938 | void VoiceKey::TestSignChangesUpdate(double & currentsignchanges, int len, |
| 939 | const float & a1, |
nothing calls this directly
no test coverage detected