Unified · Split
| @@ -284,6 +284,9 @@ development of this version. https://chuck.stanford.edu/webchuck/ · 283 unmodified lines | ||
| 284 | 284 | provide additional information in the compiler error message |
| 285 | 285 | - (fixed) overloaded functions with identical arguments now will |
| 286 | 286 | correctly result in a compiler error |
| 287 | + - (fixed, hopefully) LPF and HPF filter explosion for small values of | |
| 288 | + .freq (<.2); now LPF.freq and HPF .freq are internally clamped to | |
| 289 | + never drop below 1. | |
| 287 | 290 | - (fixed) SndBuf crash in cases where file size is integer multiple |
| 288 | 291 | of .chunks and .chunks > 0 and reaching the end of the file |
| 289 | 292 | - (fixed) SndBuf.valueAt(n) for n == file size in samples now returns 0; |
| @@ -295,6 +298,7 @@ development of this version. https://chuck.stanford.edu/webchuck/ · 5 unmodified lines | ||
| 295 | 298 | were incorrectly overloaded as "loop()" and was unavailable |
| 296 | 299 | - (fixed) FileIO.seek() previously fails if EOF is reached in reading |
| 297 | 300 | a file; FileIO.seek() now functions after EOF is reached. |
| 301 | + - (updated) all cherr prints now flushes immediately | |
| 298 | 302 | - (updated) IO.newline() or a solitary "\n" now automatically flushes |
| 299 | 303 | chout |
| 300 | 304 | - (added) examples in io |
| @@ -3890,20 +3890,24 @@ t_CKBOOL Chuck_IO_Cherr::eof() · 3889 unmodified lines | ||
| 3890 | 3890 | void Chuck_IO_Cherr::write( const std::string & val ) |
| 3891 | 3891 | { |
| 3892 | 3892 | m_buffer << val; |
| 3893 | − if( val == "\n" ) flush(); | |
| 3893 | + flush(); // always flush for cerr | 1.4.2.1 (ge) added | |
| 3894 | + // if( val == "\n" ) flush(); | |
| 3894 | 3895 | } |
| 3895 | 3896 | |
| 3896 | 3897 | void Chuck_IO_Cherr::write( t_CKINT val ) |
| 3897 | 3898 | { |
| 3898 | 3899 | m_buffer << val; |
| 3900 | + flush(); // always flush for cerr | 1.4.2.1 (ge) added | |
| 3899 | 3901 | } |
| 3900 | 3902 | |
| 3901 | 3903 | void Chuck_IO_Cherr::write( t_CKINT val, t_CKINT flags ) |
| 3902 | 3904 | { |
| 3903 | 3905 | m_buffer << val; |
| 3906 | + flush(); // always flush for cerr | 1.4.2.1 (ge) added | |
| 3904 | 3907 | } |
| 3905 | 3908 | |
| 3906 | 3909 | void Chuck_IO_Cherr::write( t_CKFLOAT val ) |
| 3907 | 3910 | { |
| 3908 | 3911 | m_buffer << val; |
| 3912 | + flush(); // always flush for cerr | 1.4.2.1 (ge) added | |
| 3909 | 3913 | } |
| @@ -722,6 +722,21 @@ struct FilterBasic_data · 721 unmodified lines | ||
| 722 | 722 | t_CKFLOAT m_Q; |
| 723 | 723 | t_CKFLOAT m_db; |
| 724 | 724 | |
| 725 | + // desperation debug tools | |
| 726 | + /* | |
| 727 | + bool blowup; | |
| 728 | + t_CKFLOAT XQ; | |
| 729 | + t_CKFLOAT Xpbw; | |
| 730 | + t_CKFLOAT Xqres; | |
| 731 | + t_CKFLOAT Xpfreq; | |
| 732 | + t_CKFLOAT XD; | |
| 733 | + t_CKFLOAT XC; | |
| 734 | + t_CKFLOAT Xcosf; | |
| 735 | + t_CKFLOAT Xnext_b1; | |
| 736 | + t_CKFLOAT Xnext_b2; | |
| 737 | + t_CKFLOAT Xnext_a0; | |
| 738 | + */ | |
| 739 | + | |
| 725 | 740 | // tick_lpf |
| 726 | 741 | inline SAMPLE tick_lpf( SAMPLE in ) |
| 727 | 742 | { |
| @@ -836,6 +851,9 @@ struct FilterBasic_data · 108 unmodified lines | ||
| 836 | 851 | // set_rlpf |
| 837 | 852 | inline void set_rlpf( t_CKFLOAT freq, t_CKFLOAT Q ) |
| 838 | 853 | { |
| 854 | + // 1.4.2.1 (ge) | added bounds to hopefully prevent any more blow-ups | |
| 855 | + freq = ck_max( 1, freq ); | |
| 856 | + | |
| 839 | 857 | t_CKFLOAT qres = ck_max( .001, 1.0/Q ); |
| 840 | 858 | t_CKFLOAT pfreq = freq * g_radians_per_sample; |
| 841 | 859 | |
| @@ -851,6 +869,19 @@ struct FilterBasic_data · 9 unmodified lines | ||
| 851 | 869 | m_a0 = (SAMPLE)next_a0; |
| 852 | 870 | m_b1 = (SAMPLE)next_b1; |
| 853 | 871 | m_b2 = (SAMPLE)next_b2; |
| 872 | + | |
| 873 | + // desperation debug measure part 1 | |
| 874 | + /* | |
| 875 | + XQ = Q; | |
| 876 | + Xqres = qres; | |
| 877 | + Xpfreq = pfreq; | |
| 878 | + XD = D; | |
| 879 | + XC = C; | |
| 880 | + Xcosf = cosf; | |
| 881 | + Xnext_b1 = next_b1; | |
| 882 | + Xnext_b2 = next_b2; | |
| 883 | + Xnext_a0 = next_a0; | |
| 884 | + */ | |
| 854 | 885 | } |
| 855 | 886 | |
| 856 | 887 | // tick_rlpf |
| @@ -868,12 +899,36 @@ struct FilterBasic_data · 11 unmodified lines | ||
| 868 | 899 | CK_DDN(m_y1); |
| 869 | 900 | CK_DDN(m_y2); |
| 870 | 901 | |
| 902 | + // desperation debug measure part 2 | |
| 903 | + // --> finding: LPF and HPF seen to be blow up when freq < 1 | |
| 904 | + /* | |
| 905 | + if( fabs(result) > 1 ) | |
| 906 | + { | |
| 907 | + std::cerr << "blow up: " << result << " " << m_freq << " " << m_Q << std::endl; | |
| 908 | + blowup = true; | |
| 909 | + | |
| 910 | + std::cerr | |
| 911 | + << " Q: " << XQ | |
| 912 | + << " qres: " << Xqres | |
| 913 | + << " pfreq: " << Xpfreq | |
| 914 | + << " D: " << XD | |
| 915 | + << " C: " << XC | |
| 916 | + << " cosf: " << Xcosf | |
| 917 | + << " next_b1: " << Xnext_b1 | |
| 918 | + << " next_b2: " << Xnext_b2 | |
| 919 | + << " next_a0: " << Xnext_a0 << std::endl; | |
| 920 | + } | |
| 921 | + */ | |
| 922 | + | |
| 871 | 923 | return result; |
| 872 | 924 | } |
| 873 | 925 | |
| 874 | 926 | // set_rhpf |
| 875 | 927 | inline void set_rhpf( t_CKFLOAT freq, t_CKFLOAT Q ) |
| 876 | 928 | { |
| 929 | + // 1.4.2.1 (ge) | added bounds to hopefully prevent any more blow-ups | |
| 930 | + freq = ck_max( 1, freq ); | |
| 931 | + | |
| 877 | 932 | t_CKFLOAT qres = ck_max( .001, 1.0/Q ); |
| 878 | 933 | t_CKFLOAT pfreq = freq * g_radians_per_sample; |
| 879 | 934 | |