History

LPF and HPF blows hopefully addressed; frequency now clamped to never go below 1.0

Ge Wang committed 3 years ago

Commit cd104eb1 parent 5561e353 files · +64 −1Browse files

Showing the changes to src (2 of 3 files). Show all

Unified · Split

2 files
  1. src/core/chuck_oo.cpp +5 −1
  2. src/core/ugen_filter.cpp +55 −0
src/core/chuck_oo.cpp+5−1
@@ -3890,20 +3890,24 @@ t_CKBOOL Chuck_IO_Cherr::eof() · 3889 unmodified lines
38903890 void Chuck_IO_Cherr::write( const std::string & val )
38913891 {
38923892 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();
38943895 }
38953896
38963897 void Chuck_IO_Cherr::write( t_CKINT val )
38973898 {
38983899 m_buffer << val;
3900+ flush(); // always flush for cerr | 1.4.2.1 (ge) added
38993901 }
39003902
39013903 void Chuck_IO_Cherr::write( t_CKINT val, t_CKINT flags )
39023904 {
39033905 m_buffer << val;
3906+ flush(); // always flush for cerr | 1.4.2.1 (ge) added
39043907 }
39053908
39063909 void Chuck_IO_Cherr::write( t_CKFLOAT val )
39073910 {
39083911 m_buffer << val;
3912+ flush(); // always flush for cerr | 1.4.2.1 (ge) added
39093913 }
src/core/ugen_filter.cpp+55−0
@@ -722,6 +722,21 @@ struct FilterBasic_data · 721 unmodified lines
722722 t_CKFLOAT m_Q;
723723 t_CKFLOAT m_db;
724724
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+
725740 // tick_lpf
726741 inline SAMPLE tick_lpf( SAMPLE in )
727742 {
@@ -836,6 +851,9 @@ struct FilterBasic_data · 108 unmodified lines
836851 // set_rlpf
837852 inline void set_rlpf( t_CKFLOAT freq, t_CKFLOAT Q )
838853 {
854+ // 1.4.2.1 (ge) | added bounds to hopefully prevent any more blow-ups
855+ freq = ck_max( 1, freq );
856+
839857 t_CKFLOAT qres = ck_max( .001, 1.0/Q );
840858 t_CKFLOAT pfreq = freq * g_radians_per_sample;
841859
@@ -851,6 +869,19 @@ struct FilterBasic_data · 9 unmodified lines
851869 m_a0 = (SAMPLE)next_a0;
852870 m_b1 = (SAMPLE)next_b1;
853871 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+ */
854885 }
855886
856887 // tick_rlpf
@@ -868,12 +899,36 @@ struct FilterBasic_data · 11 unmodified lines
868899 CK_DDN(m_y1);
869900 CK_DDN(m_y2);
870901
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+
871923 return result;
872924 }
873925
874926 // set_rhpf
875927 inline void set_rhpf( t_CKFLOAT freq, t_CKFLOAT Q )
876928 {
929+ // 1.4.2.1 (ge) | added bounds to hopefully prevent any more blow-ups
930+ freq = ck_max( 1, freq );
931+
877932 t_CKFLOAT qres = ck_max( .001, 1.0/Q );
878933 t_CKFLOAT pfreq = freq * g_radians_per_sample;
879934

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t