Shop OBEX P1 Docs P2 Docs Learn Events
reSound question — Parallax Forums

reSound question

I'm converting one of the reSound examples to C and I'm wondering why this code does coginit:
PUB start
  coginit(cogid, reSoundSampleDemo, @stack)

PUB reSoundSampleDemo | input1, input2, input3
Why not just this:
PUB start | input1, input2, input3

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2020-05-26 19:04
    Here is my first attempt at converting a reSound Spin sample to C. Thie included files contain the data that was originally including using the "file" in Spin. They are very large files and take a long time to compile with fastspin. In addition, I get a number of errors.

    Here is my translated code and below that are the errors I got. Some are due to my attempt to replace "sound#SIGNED16" with "sound.SIGNED16". I'm not sure what caused the others.
    #include <stdint.h>
    
    // config PLL, 20MHz/2*25*1 = 250MHz
    #define my_clkmode          0b1_000001_0000011000_1111_10_00 
    #define my_clkfreq          250_000_000
    
    #define OUTPUT_PIN_LEFT     14
    #define OUTPUT_PIN_RIGHT    15
    #define MIXING_FREQ         88200 
    #define NR_INPUT_CHANNELS   3
    #define HZ                  0x8000_0000
    
    struct __using("reSound.spin2") sound;
    
    int32_t resoundHubFootprint[64];
    
    #include "kick.c"
    #include "hihat.c"
    #include "snare.c"
    
    
    void main()
    {
      int32_t input1, input2, input3;
      
      clkset(my_clkmode, my_clkfreq);
    
      // Initialize and start reSound using a mixing rate of 88200 Hz, with 3 input channels and stereo output
      sound.init(clkfreq, MIXING_FREQ, true, NR_INPUT_CHANNELS, OUTPUT_PIN_LEFT, OUTPUT_PIN_RIGHT, -1, true, resoundHubFootprint);
    
      // Configure 3 input channels using 16 bit signed format 
      input1 = sound.configureInput(0, 0, 65536, 0, -1& sound.SIGNED16, 0);                         
      input2 = sound.configureInput(0, 0, 65536, 0, -1& sound.SIGNED16, 0);
      input3 = sound.configureInput(0, 0, 65536, 0, -1& sound.SIGNED16, 0);
    
      sound.start();
    
      for (;;) { // Play a little beat
    
        // 1 / 4 
        sound.playSample(input1, kick_array,  kick_size,  1, 44100|Hz, 12000, 32768);
        sound.playSample(input2, hihat_array, hihat_size, 1, 44100|Hz, 2000, 65535);
        waitcnt(CNT + 70_000_000); 
    
        // 2 / 4
        sound.playSample(input2, hihat_array, hihat_size, 1, 44100|Hz, 4000, 32768);
        waitcnt(CNT + 70_000_000);
    
        // 3 / 4
        sound.playSample(input1, kick_array,  kick_size,  1, 44100|Hz, 12000, 32768);
        sound.playSample(input3, snare_array, snare_size, 1, 44100|Hz, 9000, 10000);
        sound.playSample(input2, hihat_array, hihat_size, 1, 44100|Hz, 2000, 0);
        waitcnt(CNT + 70_000_000);
    
        // 4 / 4
        sound.playSample(input1, kick_array,  kick_size,  1, 44100|Hz, 12000, 32768);
        sound.playSample(input2, hihat_array, hihat_size, 1, 44100|Hz, 2000, 32768);
        waitcnt(CNT + 70_000_000);
      }
    }
    

    And here are the errors I got:
    dbetz@Davids-Mac-mini-2 synth % fastspin -2 resound-sample.c
    Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2020 Total Spectrum Software Inc.
    Version 4.1.12-beta-16f7a5c0 Compiled on: May 25 2020
    resound-sample.c
    |-reSound.spin2
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: unknown identifier SIGNED16 in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: SIGNED16 is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: unknown identifier SIGNED16 in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: SIGNED16 is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: unknown identifier SIGNED16 in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: SIGNED16 is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:43: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:43: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:44: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:44: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:48: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:48: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:52: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:52: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:53: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:53: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:54: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:54: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:58: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:58: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:59: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:59: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: unknown identifier SIGNED16 in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: SIGNED16 is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:34: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: unknown identifier SIGNED16 in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: SIGNED16 is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:35: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: unknown identifier SIGNED16 in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: SIGNED16 is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: unknown identifier configureInput in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:36: error: configureInput is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:43: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:43: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:43: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:43: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:44: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:44: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:44: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:44: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:48: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:48: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:48: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:48: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:52: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:52: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:52: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:52: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:53: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:53: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:53: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:53: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:54: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:54: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:54: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:54: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:58: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:58: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:58: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:58: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:59: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:59: error: playSample is not a member of reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:59: error: unknown identifier playSample in class reSound
    /Users/dbetz/Dropbox/work/synth/resound-sample.c:59: error: playSample is not a member of reSound
    
  • In Spin everything is lower case, at least as far as C is concerned.
  • David BetzDavid Betz Posts: 14,516
    edited 2020-05-27 00:52
    Here is C code that produces some sound but it doesn't seem like the clock is set correctly. Also, it still takes a long time to compile with fastspin. I've attached all of the sources in a zip file.

    @ersmith Do you know why this takes a long time to compiler with fastspin?
    #include <stdint.h>
    
    // config PLL, 20MHz/2*25*1 = 250MHz
    #define my_clkmode          0b1_000001_0000011000_1111_10_00 
    #define my_clkfreq          250_000_000
    
    #define OUTPUT_PIN_LEFT     14
    #define OUTPUT_PIN_RIGHT    15
    #define MIXING_FREQ         88200 
    #define NR_INPUT_CHANNELS   3
    #define Hz                  0x8000_0000
    
    struct __using("reSound.spin2") sound;
    
    int32_t resoundHubFootprint[64];
    #include "kick.c"
    #include "hihat.c"
    #include "snare.c"
    
    void main()
    {
      int32_t input1, input2, input3;
      
      clkset(my_clkmode, my_clkfreq);
    
      // Initialize and start reSound using a mixing rate of 88200 Hz, with 3 input channels and stereo output
      sound.init(clkfreq, MIXING_FREQ, true, NR_INPUT_CHANNELS, OUTPUT_PIN_LEFT, OUTPUT_PIN_RIGHT, -1, true, resoundHubFootprint);
    
      // Configure 3 input channels using 16 bit signed format 
      input1 = sound.configureinput(0, 0, 65536, 0, -1& sound.signed16, 0);                         
      input2 = sound.configureinput(0, 0, 65536, 0, -1& sound.signed16, 0);
      input3 = sound.configureinput(0, 0, 65536, 0, -1& sound.signed16, 0);
    
      sound.start();
    
      for (;;) { // Play a little beat
    
        // 1 / 4 
        sound.playsample(input1, kick_array,  kick_size,  1, 44100|Hz, 12000, 32768);
        sound.playsample(input2, hihat_array, hihat_size, 1, 44100|Hz, 2000, 65535);
        waitcnt(cnt + 70_000_000); 
    
        // 2 / 4
        sound.playsample(input2, hihat_array, hihat_size, 1, 44100|Hz, 4000, 32768);
        waitcnt(cnt + 70_000_000);
    
        // 3 / 4
        sound.playsample(input1, kick_array,  kick_size,  1, 44100|Hz, 12000, 32768);
        sound.playsample(input3, snare_array, snare_size, 1, 44100|Hz, 9000, 10000);
        sound.playsample(input2, hihat_array, hihat_size, 1, 44100|Hz, 2000, 0);
        waitcnt(cnt + 70_000_000);
    
        // 4 / 4
        sound.playsample(input1, kick_array,  kick_size,  1, 44100|Hz, 12000, 32768);
        sound.playsample(input2, hihat_array, hihat_size, 1, 44100|Hz, 2000, 32768);
        waitcnt(cnt + 70_000_000);
      }
    }
    
  • roglohrogloh Posts: 5,787
    edited 2020-05-26 23:21
    David Betz wrote: »
    I'm converting one of the reSound examples to C and I'm wondering why this code does coginit:
    PUB start
      coginit(cogid, reSoundSampleDemo, @stack)
    
    PUB reSoundSampleDemo | input1, input2, input3
    
    Why not just this:
    PUB start | input1, input2, input3
    

    Starting like this gives you control of where you want your stack and its size.
  • rogloh wrote: »
    David Betz wrote: »
    I'm converting one of the reSound examples to C and I'm wondering why this code does coginit:
    PUB start
      coginit(cogid, reSoundSampleDemo, @stack)
    
    PUB reSoundSampleDemo | input1, input2, input3
    
    Why not just this:
    PUB start | input1, input2, input3
    

    Starting like this gives you control of where you want your stack and its size.
    Is there a requirement that the stack be in a particular place? Maybe that's why my C version is behaving oddly?

  • You should be able to put your stack anywhere in allocated DAT or VAR storage locations so long as it doesn't overflow. Whether it grows up or down might be an issue. In C typically stacks grow down while in SPIN1 they grow up, not sure what they do in SPIN2/Fastspin.
  • David Betz wrote: »
    Here is C code that produces some sound but it doesn't seem like the clock is set correctly. Also, it still takes a long time to compile with fastspin. I've attached all of the sources in a zip file.

    @ersmith Do you know why this takes a long time to compiler with fastspin?

    Parsing of large initializers was using an O(n^2) algorithm. I've improved that, the current github is still a bit slower than I'd like but much much better than before.
  • ersmith wrote: »
    David Betz wrote: »
    Here is C code that produces some sound but it doesn't seem like the clock is set correctly. Also, it still takes a long time to compile with fastspin. I've attached all of the sources in a zip file.

    @ersmith Do you know why this takes a long time to compiler with fastspin?

    Parsing of large initializers was using an O(n^2) algorithm. I've improved that, the current github is still a bit slower than I'd like but much much better than before.
    Wow! It went from 48 seconds to .39 seconds! Thanks!!!

  • Ahle2Ahle2 Posts: 1,179
    edited 2020-05-27 11:17
    David,
    Is it working now, or is something funky with the system clock or mixing rate?
  • Ahle2 wrote: »
    David,
    Is it working now, or is something funky with the system clock or mixing rate?
    It's still not working. I hear what I think is a hi-hat sound and then a long pause and then something that sounds like a machine gun. Might be a corruption of the snare sound.

  • Here is my current code:
    #include <stdint.h>
    #include <propeller.h>
    
    // config PLL, 20MHz/2*25*1 = 250MHz
    #define my_clkmode          0b1_000001_0000011000_1111_10_00 
    #define my_clkfreq          250_000_000
    
    #define OUTPUT_PIN_LEFT     14
    #define OUTPUT_PIN_RIGHT    15
    #define MIXING_FREQ         88200 
    #define NR_INPUT_CHANNELS   3
    #define Hz                  0x8000_0000
    
    struct __using("reSound.spin2") sound;
    
    int32_t resoundHubFootprint[64];
    
    #include "kick.c"
    #include "hihat.c"
    #include "snare.c"
    
    void main()
    {
      int32_t input1, input2, input3;
      
      _clkset(my_clkmode, my_clkfreq);
    
      // Initialize and start reSound using a mixing rate of 88200 Hz, with 3 input channels and stereo output
      sound.init(clkfreq, MIXING_FREQ, true, NR_INPUT_CHANNELS, OUTPUT_PIN_LEFT, OUTPUT_PIN_RIGHT, -1, true, resoundHubFootprint);
    
      // Configure 3 input channels using 16 bit signed format 
      input1 = sound.configureinput(0, 0, 65536, 0, -1& sound.signed16, 0);                         
      input2 = sound.configureinput(0, 0, 65536, 0, -1& sound.signed16, 0);
      input3 = sound.configureinput(0, 0, 65536, 0, -1& sound.signed16, 0);
    
      sound.start();
    
      for (;;) { // Play a little beat
    
        // 1 / 4 
        sound.playsample(input1, kick_array,  kick_size/2,  1, 44100|Hz, 12000, 32768);
        sound.playsample(input2, hihat_array, hihat_size/2, 1, 44100|Hz, 2000, 65535);
        waitcnt(cnt + 70_000_000); 
    
        // 2 / 4
        sound.playsample(input2, hihat_array, hihat_size/2, 1, 44100|Hz, 4000, 32768);
        waitcnt(cnt + 70_000_000);
    
        // 3 / 4
        sound.playsample(input1, kick_array,  kick_size/2,  1, 44100|Hz, 12000, 32768);
        sound.playsample(input3, snare_array, snare_size/2, 1, 44100|Hz, 9000, 10000);
        sound.playsample(input2, hihat_array, hihat_size/2, 1, 44100|Hz, 2000, 0);
        waitcnt(cnt + 70_000_000);
    
        // 4 / 4
        sound.playsample(input1, kick_array,  kick_size/2,  1, 44100|Hz, 12000, 32768);
        sound.playsample(input2, hihat_array, hihat_size/2, 1, 44100|Hz, 2000, 32768);
        waitcnt(cnt + 70_000_000);
      }
    }
    
  • I added a printf to the code to print the value of clkfreq after calling clkset and it does print 250000000 so I guess the clock frequency is being set correctly.
  • Ahle2Ahle2 Posts: 1,179
    Test to use "my_clkfreq" instead of "clkfreq" in the init call.
  • Ahle2 wrote: »
    Test to use "my_clkfreq" instead of "clkfreq" in the init call.
    Our posts must have crossed. I have already verified that clkfreq has the correct value after the clkset call.

  • Ahle2Ahle2 Posts: 1,179
    I will download and test this when I have got the time.
  • Ahle2 wrote: »
    I will download and test this when I have got the time.
    I hope I didn't make some dumb editing error that is causing this problem. Also, can you point me to an example that uses a single sample file and resamples it for different frequencies/pitches?

  • Ahle2Ahle2 Posts: 1,179
    edited 2020-05-28 11:28
    David,

    Changing all "waitcnt(cnt + 70_000_000);" to "waitx(70_000_000);" fixed the problem.
    The question is why the waitcnt() function behaves differently on Spin2 and C... Eric?!

    To answer your question regarding the pitch/frequency; Just change the "44100|Hz" to any sample rate you would like to replay at. (The original samples are sampled at 44100 Hz) This can be independantly set for all inputs.
  • Ahle2 wrote: »
    David,

    Changing all "waitcnt(cnt + 70_000_000);" to "waitx(70_000_000);" fixed the problem.
    The question is why the waitcnt() function behaves differently on Spin2 and C... Eric?!

    To answer your question regarding the pitch/frequency; Just change the "44100|Hz" to any sample rate you would like to replay at. (The original samples are sampled at 44100 Hz) This can be independantly set for all inputs.
    That's great! It works for me now as well. Here is the final working version. And thanks also for the advice about resampling at a different frequency. I'll give it a try.
    #include <stdint.h>
    #include <propeller.h>
    
    // config PLL, 20MHz/2*25*1 = 250MHz
    #define my_clkmode          0b1_000001_0000011000_1111_10_00 
    #define my_clkfreq          250_000_000
    
    #define OUTPUT_PIN_LEFT     14
    #define OUTPUT_PIN_RIGHT    15
    #define MIXING_FREQ         88200 
    #define NR_INPUT_CHANNELS   3
    #define Hz                  0x8000_0000
    
    struct __using("reSound.spin2") sound;
    
    int32_t resoundHubFootprint[64];
    
    #include "kick.c"
    #include "hihat.c"
    #include "snare.c"
    
    void main()
    {
      int32_t input1, input2, input3;
      
      _clkset(my_clkmode, my_clkfreq);
    
      // Initialize and start reSound using a mixing rate of 88200 Hz, with 3 input channels and stereo output
      sound.init(clkfreq, MIXING_FREQ, true, NR_INPUT_CHANNELS, OUTPUT_PIN_LEFT, OUTPUT_PIN_RIGHT, -1, true, resoundHubFootprint);
    
      // Configure 3 input channels using 16 bit signed format 
      input1 = sound.configureInput(0, 0, 65536, 0, -1& sound.SIGNED16, 0);                         
      input2 = sound.configureInput(0, 0, 65536, 0, -1& sound.SIGNED16, 0);
      input3 = sound.configureInput(0, 0, 65536, 0, -1& sound.SIGNED16, 0);
    
      sound.start();
    
      for (;;) { // Play a little beat
    
        // 1 / 4 
        sound.playSample(input1, kick_array,  kick_size/2,  1, 44100|Hz, 12000, 32768);
        sound.playSample(input2, hihat_array, hihat_size/2, 1, 44100|Hz, 2000, 65535);
        waitx(70_000_000); 
    
        // 2 / 4
        sound.playSample(input2, hihat_array, hihat_size/2, 1, 44100|Hz, 4000, 32768);
        waitx(70_000_000);
    
        // 3 / 4
        sound.playSample(input1, kick_array,  kick_size/2,  1, 44100|Hz, 12000, 32768);
        sound.playSample(input3, snare_array, snare_size/2, 1, 44100|Hz, 9000, 10000);
        sound.playSample(input2, hihat_array, hihat_size/2, 1, 44100|Hz, 2000, 0);
        waitx(70_000_000);
    
        // 4 / 4
        sound.playSample(input1, kick_array,  kick_size/2,  1, 44100|Hz, 12000, 32768);
        sound.playSample(input2, hihat_array, hihat_size/2, 1, 44100|Hz, 2000, 32768);
        waitx(70_000_000);
      }
    }
    

  • ersmithersmith Posts: 6,053
    edited 2020-05-28 11:46
    The problem is confusion between a builtin function "cnt" (which must be called with arguments) and "CNT" (a macro), compounded by the fact that waitcnt is written in Spin and hence does not have any argument checking. I'll see if I can get rid of "cnt()" in C so that the original code will give an error.
  • ersmith wrote: »
    The problem is confusion between a builtin function "cnt" (which must be called with arguments) and "CNT" (a macro), compounded by the fact that waitcnt is written in Spin and hence does not have any argument checking. I'll see if I can get rid of "cnt()" in C so that the original code will give an error.
    Sure enough, if I change "cnt" to "CNT" the original code works with the waitcnt() function calls. Thanks, Eric!

Sign In or Register to comment.