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
3890void Chuck_IO_Cherr::write( const std::string & val )3890void Chuck_IO_Cherr::write( const std::string & val )
3891{3891{
3892 m_buffer << val;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
3896void Chuck_IO_Cherr::write( t_CKINT val )3897void Chuck_IO_Cherr::write( t_CKINT val )
3897{3898{
3898 m_buffer << val;3899 m_buffer << val;
3900 flush(); // always flush for cerr | 1.4.2.1 (ge) added
3899}3901}
3900 3902
3901void Chuck_IO_Cherr::write( t_CKINT val, t_CKINT flags )3903void Chuck_IO_Cherr::write( t_CKINT val, t_CKINT flags )
3902{3904{
3903 m_buffer << val;3905 m_buffer << val;
3906 flush(); // always flush for cerr | 1.4.2.1 (ge) added
3904}3907}
3905 3908
3906void Chuck_IO_Cherr::write( t_CKFLOAT val )3909void Chuck_IO_Cherr::write( t_CKFLOAT val )
3907{3910{
3908 m_buffer << val;3911 m_buffer << val;
3912 flush(); // always flush for cerr | 1.4.2.1 (ge) added
3909}3913}
src/core/ugen_filter.cpp+55−0
@@ -722,6 +722,21 @@ struct FilterBasic_data · 721 unmodified lines
722 t_CKFLOAT m_Q;722 t_CKFLOAT m_Q;
723 t_CKFLOAT m_db;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 // tick_lpf740 // tick_lpf
726 inline SAMPLE tick_lpf( SAMPLE in )741 inline SAMPLE tick_lpf( SAMPLE in )
727 {742 {
@@ -836,6 +851,9 @@ struct FilterBasic_data · 108 unmodified lines
836 // set_rlpf851 // set_rlpf
837 inline void set_rlpf( t_CKFLOAT freq, t_CKFLOAT Q )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 t_CKFLOAT qres = ck_max( .001, 1.0/Q );857 t_CKFLOAT qres = ck_max( .001, 1.0/Q );
840 t_CKFLOAT pfreq = freq * g_radians_per_sample;858 t_CKFLOAT pfreq = freq * g_radians_per_sample;
841 859
@@ -851,6 +869,19 @@ struct FilterBasic_data · 9 unmodified lines
851 m_a0 = (SAMPLE)next_a0;869 m_a0 = (SAMPLE)next_a0;
852 m_b1 = (SAMPLE)next_b1;870 m_b1 = (SAMPLE)next_b1;
853 m_b2 = (SAMPLE)next_b2;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 // tick_rlpf887 // tick_rlpf
@@ -868,12 +899,36 @@ struct FilterBasic_data · 11 unmodified lines
868 CK_DDN(m_y1);899 CK_DDN(m_y1);
869 CK_DDN(m_y2);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 return result;923 return result;
872 }924 }
873 925
874 // set_rhpf926 // set_rhpf
875 inline void set_rhpf( t_CKFLOAT freq, t_CKFLOAT Q )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 t_CKFLOAT qres = ck_max( .001, 1.0/Q );932 t_CKFLOAT qres = ck_max( .001, 1.0/Q );
878 t_CKFLOAT pfreq = freq * g_radians_per_sample;933 t_CKFLOAT pfreq = freq * g_radians_per_sample;
879 934

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