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

Thread: Beep in audio when compiling with Serial+MIDI+Audio

  1. #1

    Beep in audio when compiling with Serial+MIDI+Audio

    Hi,
    when I compile my sketch with "Serial + MIDI + Audio" I get a beep cutting of the audio from the headphone jack.
    (The beep sounds like a squarewave at 440hz or something you get when using a trial version of a software)
    When recording the audio, there is no beep on the recording.
    It does not matter if I comment out the "USB out" in my audio design, the beep in the headphones is still there.
    When the beep is playing the USB MIDI "freezes".

    When I compile my sketch with "Serial + MIDI" the beep in the headphone jack is gone, and USB MIDI works fine.

    The audio memory is set at 20.

    I would post my code but the sketch is around 2000 lines so I'll just post the audio design:

    Code:
    AudioSynthWaveformDc     pitchEnvelopeAmount; //xy=1365,1958
    AudioSynthWaveform       pitchLFO;       //xy=1526,1887
    AudioEffectEnvelope      pitchEnvelope;  //xy=1550,1956
    AudioSynthWaveform       PWMLFO;      //xy=1739,2017
    AudioMixer4              pitchModulationMixer; //xy=1760,1888
    AudioSynthWaveform       FMModulationWaveform; //xy=1844,1760
    AudioSynthWaveformDc     filterEnvelopeAmount; //xy=2037,2452
    AudioSynthNoiseWhite     whiteNoise2;    //xy=2086,2001
    AudioSynthNoiseWhite     whiteNoise3;    //xy=2087,2150
    AudioSynthWaveformModulated oscillator3;    //xy=2088,2075
    AudioSynthNoiseWhite     whiteNoise4;    //xy=2088,2302
    AudioSynthNoisePink      pinkNoise3;     //xy=2089,2191
    AudioSynthNoisePink      pinkNoise2;     //xy=2090,2039
    AudioSynthNoisePink      pinkNoise4;     //xy=2090,2340
    AudioSynthNoiseWhite     whiteNoise1;    //xy=2092,1850
    AudioSynthWaveformModulated oscillator4;    //xy=2092,2228
    AudioSynthNoisePink      pinkNoise1;     //xy=2094,1891
    AudioSynthWaveformModulated oscillator2;    //xy=2094,1929
    AudioSynthWaveformModulated oscillator1;    //xy=2096,1778
    AudioSynthWaveformSineModulated FM3;            //xy=2099,2113
    AudioSynthWaveformSineModulated FM2;            //xy=2102,1966
    AudioSynthWaveformSineModulated FM4;            //xy=2101,2265
    AudioSynthWaveformSineModulated FM1;            //xy=2104,1813
    AudioSynthWaveform       filterLFO;      //xy=2226,2406
    AudioEffectEnvelope      filterEnvelope; //xy=2229,2453
    AudioMixer4              oscillatorMixer1; //xy=2286,1797
    AudioMixer4              oscillatorMixer2; //xy=2287,1939
    AudioMixer4              oscillatorMixer4; //xy=2286,2233
    AudioMixer4              oscillatorMixer3; //xy=2290,2097
    AudioMixer4              filterModulationMixer; //xy=2474,2428
    AudioMixer4              oscillatorMixerL; //xy=2506,1975
    AudioMixer4              oscillatorMixerR; //xy=2507,2068
    AudioFilterLadder        filter1Ladder;        //xy=2667.1432189941406,2028.5712928771973
    AudioFilterLadder        filter2Ladder; //xy=2668.571578979492,2121.4286251068115
    AudioFilterStateVariable filter1;        //xy=2682,1981
    AudioFilterStateVariable filter2;        //xy=2683,2073
    AudioMixer4              filterMixerL;   //xy=2830,1987
    AudioMixer4              filterMixerR;   //xy=2831,2082
    AudioEffectEnvelope      amplifierEnvelopeL; //xy=3016,1987
    AudioEffectEnvelope      amplifierEnvelopeR; //xy=3018,2080
    AudioOutputI2S           i2s1;           //xy=3227,2031
    AudioOutputUSB           usb1;           //xy=3228,1978
    AudioConnection          patchCord1(pitchEnvelopeAmount, pitchEnvelope);
    AudioConnection          patchCord2(pitchLFO, 0, pitchModulationMixer, 0);
    AudioConnection          patchCord3(pitchEnvelope, 0, pitchModulationMixer, 1);
    AudioConnection          patchCord4(PWMLFO, 0, oscillator1, 1);
    AudioConnection          patchCord5(PWMLFO, 0, oscillator2, 1);
    AudioConnection          patchCord6(PWMLFO, 0, oscillator3, 1);
    AudioConnection          patchCord7(PWMLFO, 0, oscillator4, 1);
    AudioConnection          patchCord8(pitchModulationMixer, 0, oscillator1, 0);
    AudioConnection          patchCord9(pitchModulationMixer, 0, oscillator2, 0);
    AudioConnection          patchCord10(pitchModulationMixer, 0, oscillator3, 0);
    AudioConnection          patchCord11(pitchModulationMixer, 0, oscillator4, 0);
    AudioConnection          patchCord12(FMModulationWaveform, FM1);
    AudioConnection          patchCord13(FMModulationWaveform, FM2);
    AudioConnection          patchCord14(FMModulationWaveform, FM3);
    AudioConnection          patchCord15(FMModulationWaveform, FM4);
    AudioConnection          patchCord16(filterEnvelopeAmount, filterEnvelope);
    AudioConnection          patchCord17(whiteNoise2, 0, oscillatorMixer2, 2);
    AudioConnection          patchCord18(whiteNoise3, 0, oscillatorMixer3, 2);
    AudioConnection          patchCord19(oscillator3, 0, oscillatorMixer3, 0);
    AudioConnection          patchCord20(whiteNoise4, 0, oscillatorMixer4, 2);
    AudioConnection          patchCord21(pinkNoise3, 0, oscillatorMixer3, 3);
    AudioConnection          patchCord22(pinkNoise2, 0, oscillatorMixer2, 3);
    AudioConnection          patchCord23(pinkNoise4, 0, oscillatorMixer4, 3);
    AudioConnection          patchCord24(whiteNoise1, 0, oscillatorMixer1, 2);
    AudioConnection          patchCord25(oscillator4, 0, oscillatorMixer4, 0);
    AudioConnection          patchCord26(pinkNoise1, 0, oscillatorMixer1, 3);
    AudioConnection          patchCord27(oscillator2, 0, oscillatorMixer2, 0);
    AudioConnection          patchCord28(oscillator1, 0, oscillatorMixer1, 0);
    AudioConnection          patchCord29(FM3, 0, oscillatorMixer3, 1);
    AudioConnection          patchCord30(FM2, 0, oscillatorMixer2, 1);
    AudioConnection          patchCord31(FM4, 0, oscillatorMixer4, 1);
    AudioConnection          patchCord32(FM1, 0, oscillatorMixer1, 1);
    AudioConnection          patchCord33(filterLFO, 0, filterModulationMixer, 0);
    AudioConnection          patchCord34(filterEnvelope, 0, filterModulationMixer, 1);
    AudioConnection          patchCord35(oscillatorMixer1, 0, oscillatorMixerL, 0);
    AudioConnection          patchCord36(oscillatorMixer1, 0, oscillatorMixerR, 0);
    AudioConnection          patchCord37(oscillatorMixer2, 0, oscillatorMixerL, 1);
    AudioConnection          patchCord38(oscillatorMixer2, 0, oscillatorMixerR, 1);
    AudioConnection          patchCord39(oscillatorMixer4, 0, oscillatorMixerL, 3);
    AudioConnection          patchCord40(oscillatorMixer4, 0, oscillatorMixerR, 3);
    AudioConnection          patchCord41(oscillatorMixer3, 0, oscillatorMixerL, 2);
    AudioConnection          patchCord42(oscillatorMixer3, 0, oscillatorMixerR, 2);
    AudioConnection          patchCord43(filterModulationMixer, 0, filter1, 1);
    AudioConnection          patchCord44(filterModulationMixer, 0, filter2, 1);
    AudioConnection          patchCord45(filterModulationMixer, 0, filter1Ladder, 1);
    AudioConnection          patchCord46(filterModulationMixer, 0, filter2Ladder, 1);
    AudioConnection          patchCord47(oscillatorMixerL, 0, filter1, 0);
    AudioConnection          patchCord48(oscillatorMixerL, 0, filter1Ladder, 0);
    AudioConnection          patchCord49(oscillatorMixerR, 0, filter2, 0);
    AudioConnection          patchCord50(oscillatorMixerR, 0, filter2Ladder, 0);
    AudioConnection          patchCord51(filter1Ladder, 0, filterMixerL, 3);
    AudioConnection          patchCord52(filter2Ladder, 0, filterMixerR, 3);
    AudioConnection          patchCord53(filter1, 0, filterMixerL, 0);
    AudioConnection          patchCord54(filter1, 1, filterMixerL, 1);
    AudioConnection          patchCord55(filter1, 2, filterMixerL, 2);
    AudioConnection          patchCord56(filter2, 0, filterMixerR, 0);
    AudioConnection          patchCord57(filter2, 1, filterMixerR, 1);
    AudioConnection          patchCord58(filter2, 2, filterMixerR, 2);
    AudioConnection          patchCord59(filterMixerL, amplifierEnvelopeL);
    AudioConnection          patchCord60(filterMixerR, amplifierEnvelopeR);
    AudioConnection          patchCord61(amplifierEnvelopeL, 0, usb1, 0);
    AudioConnection          patchCord62(amplifierEnvelopeL, 0, i2s1, 0);
    AudioConnection          patchCord63(amplifierEnvelopeR, 0, usb1, 1);
    AudioConnection          patchCord64(amplifierEnvelopeR, 0, i2s1, 1);
    AudioControlSGTL5000     TeensyAudio;    //xy=3230,2083
    Anyone with any idea of what's wrong?

    /Johan

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,044
    Have you used AudioMemoryUsage() and AudioMemoryUsageMax()? You have a lot of objects, 20 blocks sounds stingy to me.

    You are perhaps hearing every other block being missing due to an inadequate number being available.

  3. #3
    I tried to increase the audio memory to 60 but no positive effect unfortunately.

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,044
    Ditto AudioProcessorUsage and AudioProcessorUsageMax() then. If the processing is taking 100% of the CPU, same
    problem...

  5. #5
    Quote Originally Posted by MarkT View Post
    Ditto AudioProcessorUsage and AudioProcessorUsageMax() then. If the processing is taking 100% of the CPU, same
    problem...
    Measured AudioProcessorUsage and AudioProcessorUsageMax as per your suggestion. It turned out to be 100 so I made the audio memory 120 and now it works perfect, thanks!

  6. #6
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,044
    That's odd as processor usage should be independent of memory use really?!

Posting Permissions

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