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

Thread: Troubles Processing MIDI

  1. #1
    Junior Member
    Join Date
    May 2018
    Location
    Baltimore
    Posts
    13

    Troubles Processing MIDI

    I am having a most perplexing problem with USB MIDI that I'm attempting to solve over video chat for my marketing partner who is a few thousand miles away from me.

    The problem:
    The serial is printing when the device receives a midi note, but there is no audio, which is odd because I used that prototype for a month without this issue cropping up.

    Products in use: Teensy 3.6, PT8211
    Wiring details: the DAC is wired the same as Paul's PT8211 Kit.
    Software setup: Arduino IDE on OSX Mojave with Italian character mapping
    Repro steps: unfortunately, I can't reproduce

    what I've discerned so far to be working:
    - This sketch plays a sine as expected Examples/Audio/HardwareTesting/PT8211Sine, so hardware is presumably okay
    - He downloaded the current Arduino and Teensyduino .dmgs, so the IDE is up to date
    - his configuration matches mine exactly in Arduino's "Tools" menu
    - he can upload sketches successfully
    - his audio and USB cables seem to be fine and we've tried others

    I gave him a stripped down sketch(works for me) to play notes in response to USB MIDI and this is where he hit problems.

    Code:
    #include <Audio.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveform       waveform1;      //xy=398,195
    AudioEffectEnvelope      envelope1;      //xy=568,200
    AudioMixer4              mixer1;         //xy=709,125
    AudioOutputPT8211           pt8211;           //xy=844,309
    AudioConnection          patchCord1(waveform1, envelope1);
    AudioConnection          patchCord2(envelope1, 0, mixer1, 0);
    AudioConnection          patchCord3(mixer1, 0, pt8211, 0);
    AudioConnection          patchCord4(mixer1, 0, pt8211, 1);
    // GUItool: end automatically generated code
    
    void setup() {
      Serial.begin(115200);
      usbMIDI.setHandleNoteOn(myNoteOn);
      usbMIDI.setHandleNoteOff(myNoteOff);
    
      AudioMemory(20);
    
      waveform1.begin(WAVEFORM_SINE);
      waveform1.amplitude(1);
    }
    
    void loop() {  
      usbMIDI.read();
    }
    
    void myNoteOn(byte channel, byte note, byte velocity) {
      float freq = 440.0 * powf(2.0, (float)(note - 69) * 0.08333333);
      waveform1.frequency(freq);
      envelope1.noteOn();
      Serial.print("note on:");
      Serial.print("frequency = ");
      Serial.println(freq);
    }
    
    void myNoteOff(byte channel, byte note, byte velocity) {
      envelope1.noteOff();
    }
    It's almost as if
    Code:
    envelope1.noteOn();
    isn't doing anything.

    To make matters trickier, he doesn't have access to the Teensy's programming button, so he can't do a hard reset.

    I've tried everything that came to mind to no avail and now I'm reaching out in case this issue is familiar to anyone. Any thoughts or ideas would be greatly appreciated.

    Here's a picture of the device for reference:
    Click image for larger version. 

Name:	60631309_604326900054500_5060046807032135680_n.jpg 
Views:	10 
Size:	79.2 KB 
ID:	16707

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,108
    When he plays a MIDI note, does he see the output from this?
    Code:
      Serial.print("note on:");
      Serial.print("frequency = ");
      Serial.println(freq);
    If so, does it report the correct frequency?

    Pete

  3. #3
    Junior Member
    Join Date
    May 2018
    Location
    Baltimore
    Posts
    13
    He definitely sees the string and I'm double checking with him that the variable is showing up and changing appropriately. I'll post that answer when he gets back to me.
    I'm fairly certain he was, but we ran that at the end of a long day and my memory is failing me.

    thanks for the reply

  4. #4
    Junior Member
    Join Date
    May 2018
    Location
    Baltimore
    Posts
    13
    Yes, the frequency is printing for him.

  5. #5
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,108
    You haven't set any gains for the mixer but for that test you don't need a mixer. Try this (or add gain for the mixer)
    Code:
    AudioSynthWaveform       waveform1;      //xy=398,195
    AudioEffectEnvelope      envelope1;      //xy=568,200
    AudioOutputPT8211           pt8211;           //xy=844,309
    AudioConnection          patchCord1(waveform1, envelope1);
    AudioConnection          patchCord3(envelope1, 0, pt8211, 0);
    AudioConnection          patchCord4(envelope1, 0, pt8211, 1);
    Pete

  6. #6
    Junior Member
    Join Date
    May 2018
    Location
    Baltimore
    Posts
    13
    Thanks, I sent him a sketch with those changes. will update

    John

  7. #7
    Junior Member
    Join Date
    May 2018
    Location
    Baltimore
    Posts
    13
    Sorry for the slow response. He tried the sketch without the mixer and still no sound. I'm truly baffled by this one.

    Chalking this up to gremlins and sending another(less rushed) prototype.

  8. #8
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,108
    I was able to test your code with a T3.6 and audio board with SGTL5000. I used the MIDI-Ox keyboard on Windows to send MIDI notes to the Teensy via USB. It works, even with the mixer at its default setting.

    Pete

  9. #9
    Junior Member
    Join Date
    Jun 2019
    Posts
    1
    Quote Originally Posted by el_supremo View Post
    You haven't set any gains for the mixer but for that test you don't need a mixer. Try this (or add gain for the mixer)
    Code:
    AudioSynthWaveform       waveform1;      //xy=398,195
    AudioEffectEnvelope      envelope1;      //xy=568,200
    AudioOutputPT8211           pt8211;           //xy=844,309
    AudioConnection          patchCord1(waveform1, envelope1);
    AudioConnection          patchCord3(envelope1, 0, pt8211, 0);
    AudioConnection          patchCord4(envelope1, 0, pt8211, 1);
    Thanks for this. This worked exactly as expected.

  10. #10
    Junior Member
    Join Date
    May 2018
    Location
    Baltimore
    Posts
    13
    I finally solved the mystery. We had different versions of teensyduino. I can't believe I missed that.

    Thanks for your help el_supremo

Posting Permissions

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