Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 12 of 12

Thread: Problems with #if #endif in audio patching file

  1. #1
    Senior Member Rolfdegen's Avatar
    Join Date
    Sep 2020
    Location
    Germany
    Posts
    286

    Problems with #if #endif in audio patching file

    Hallo Teensy Friends..

    I have problems with #if #endif in my AudioPatching.h file in teensy audio lib.

    I wrote code for two filter types. With #if and #endif I want to initialize State Variable Filter or Ladder Filter in my AudioPatching.h file.
    But only the ladder filter is initialized.


    Code:
    // Filter 1 = State Variable Filter
    // Filter 2 = Ladder Filter
    
    #define Filter 1
    
    #if Filter == 1
        AudioFilterStateVariable filter1;        //xy=1000,210
        AudioFilterStateVariable filter2;        //xy=994,498
        AudioFilterStateVariable filter3;        //xy=1002,822
        AudioFilterStateVariable filter4;        //xy=1022,1047
        AudioFilterStateVariable filter5;        //xy=1002,822
        AudioFilterStateVariable filter6;        //xy=1022,1047
        AudioFilterStateVariable filter7;        //xy=994,498
        AudioFilterStateVariable filter8;        //xy=1000,210
    #else
        AudioFilterLadder filter1;        //xy=1000,210
        AudioFilterLadder filter2;        //xy=994,498
        AudioFilterLadder filter3;        //xy=1002,822
        AudioFilterLadder filter4;        //xy=1022,1047
        AudioFilterLadder filter5;        //xy=1002,822
        AudioFilterLadder filter6;        //xy=1022,1047
        AudioFilterLadder filter7;        //xy=994,498
        AudioFilterLadder filter8;        //xy=1000,210
    #endif
    Thanks for help

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Works for me.

    Looks like you have defined "Filter" elsewhere, earlier(?)

  3. #3
    Senior Member Rolfdegen's Avatar
    Join Date
    Sep 2020
    Location
    Germany
    Posts
    286
    Yes it is initialized in another h.file

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    So, it's not loaded.

  5. #5
    Senior Member Rolfdegen's Avatar
    Join Date
    Sep 2020
    Location
    Germany
    Posts
    286
    Is there another way without having to comment out a filter ? see example

    Code:
     AudioFilterStateVariable filter1; //xy=1000.210
        AudioFilterStateVariable filter2; //xy=994.498
        AudioFilterStateVariable filter3; //xy=1002.822
        AudioFilterStateVariable filter4; //xy=1022,1047
        AudioFilterStateVariable filter5; //xy=1002.822
        AudioFilterStateVariable filter6; //xy=1022,1047
        AudioFilterStateVariable filter7; //xy=994.498
        AudioFilterStateVariable filter8; //xy=1000.210
    
    /*
        AudioFilterLeiterfilter1; //xy=1000.210
        AudioFilterLeiterfilter2; //xy=994.498
        AudioFilterLeiterfilter3; //xy=1002.822
        AudioFilterLeiterfilter4; //xy=1022,1047
        AudioFilterLeiterfilter5; //xy=1002.822
        AudioFilterLeiterfilter6; //xy=1022,1047
        AudioFilterLeiterfilter7; //xy=994.498
        AudioFilterLeiterfilter8; //xy=1000.210
    */

  6. #6
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Yes, use your define. It works... du you have a #include in that file which includes the files where the #define is? It will work.
    Or, do you see a warning... it might be defined twice?

    There is nothing special about Teensyduino. It just uses GCC which, trust me, can handle this... that is used in millions of projects.
    TD uses that too to compile different code for different Teensy models...

  7. #7
    Senior Member Rolfdegen's Avatar
    Join Date
    Sep 2020
    Location
    Germany
    Posts
    286
    an #include leads to a compiler error

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    Aha Then this is the real problem

    Which error?

  9. #9
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,756
    I'm going to sleep now. Good night.

  10. #10
    Senior Member Rolfdegen's Avatar
    Join Date
    Sep 2020
    Location
    Germany
    Posts
    286
    The compiler does not show an exact error. Must be in the ino.File

  11. #11
    Senior Member Rolfdegen's Avatar
    Join Date
    Sep 2020
    Location
    Germany
    Posts
    286
    Ok. WŁnsche Dir auch eine gute Nacht

  12. #12
    Senior Member Rolfdegen's Avatar
    Join Date
    Sep 2020
    Location
    Germany
    Posts
    286
    I found a solution.

    I simply wrote the "Filter" definition into the AudioPatching.h file. I can also use it in my ino File.

    Code:
    // Jeannie Synthesizer AudioPatchhing.h
    
    // Filter 1 = State Variable Filter
    // Filter 2 = Ladder Filter
    #define Filter 1
    
    ...
    
    #if Filter == 1
        AudioFilterStateVariable filter1;        //xy=1000,210
        AudioFilterStateVariable filter2;        //xy=994,498
        AudioFilterStateVariable filter3;        //xy=1002,822
        AudioFilterStateVariable filter4;        //xy=1022,1047
        AudioFilterStateVariable filter5;        //xy=1002,822
        AudioFilterStateVariable filter6;        //xy=1022,1047
        AudioFilterStateVariable filter7;        //xy=994,498
        AudioFilterStateVariable filter8;        //xy=1000,210
    #else
        AudioFilterLadder filter1;        //xy=1000,210
        AudioFilterLadder filter2;        //xy=994,498
        AudioFilterLadder filter3;        //xy=1002,822
        AudioFilterLadder filter4;        //xy=1022,1047
        AudioFilterLadder filter5;        //xy=1002,822
        AudioFilterLadder filter6;        //xy=1022,1047
        AudioFilterLadder filter7;        //xy=994,498
        AudioFilterLadder filter8;        //xy=1000,210
    #endif
    
    ...
    Thank for help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •