| 903 | } |
| 904 | |
| 905 | int klatt::synth(int aSampleCount, short *aSamplePointer) |
| 906 | { |
| 907 | short *samp = aSamplePointer; |
| 908 | |
| 909 | if (mElementIndex >= mElementCount) |
| 910 | return -1; |
| 911 | |
| 912 | Element * currentElement = &gElement[mElement[mElementIndex++]]; |
| 913 | int dur = mElement[mElementIndex++]; |
| 914 | mElementIndex++; // skip stress |
| 915 | |
| 916 | if (currentElement->mRK == 31) // "END" |
| 917 | { |
| 918 | // Reset the fundamental frequency top |
| 919 | mFrame.mF0FundamentalFreq = mBaseF0; |
| 920 | mTop = 1.1f * mFrame.mF0FundamentalFreq; |
| 921 | } |
| 922 | |
| 923 | // Skip zero length elements which are only there to affect |
| 924 | // boundary values of adjacent elements |
| 925 | |
| 926 | if (dur > 0) |
| 927 | { |
| 928 | Element * ne = (mElementIndex < mElementCount) ? &gElement[mElement[mElementIndex]] : &gElement[0]; |
| 929 | Slope start[ELM_COUNT]; |
| 930 | Slope end[ELM_COUNT]; |
| 931 | int t; |
| 932 | |
| 933 | if (currentElement->mRK > mLastElement->mRK) |
| 934 | { |
| 935 | set_trans(start, currentElement, mLastElement, 0, 's'); |
| 936 | // we dominate last |
| 937 | } |
| 938 | else |
| 939 | { |
| 940 | set_trans(start, mLastElement, currentElement, 1, 's'); |
| 941 | // last dominates us |
| 942 | } |
| 943 | |
| 944 | if (ne->mRK > currentElement->mRK) |
| 945 | { |
| 946 | set_trans(end, ne, currentElement, 1, 'e'); |
| 947 | // next dominates us |
| 948 | } |
| 949 | else |
| 950 | { |
| 951 | set_trans(end, currentElement, ne, 0, 'e'); |
| 952 | // we dominate next |
| 953 | } |
| 954 | |
| 955 | for (t = 0; t < dur; t++, mTStress++) |
| 956 | { |
| 957 | float base = mTop * 0.8f; // 3 * top / 5 |
| 958 | float tp[ELM_COUNT]; |
| 959 | int j; |
| 960 | |
| 961 | if (mTStress == mNTStress) |
| 962 | { |
no test coverage detected