Arduino Midi Controller and USB audio

Discussion in 'Embedded Systems and Microcontrollers' started by stefan.54, Feb 5, 2016.

  1. stefan.54

    Thread Starter New Member

    Dec 26, 2015
    28
    4
    Hey, AAC guys!

    I'm currently building an arduino-based dj controller (pots, switches, led and so on).I'm also using Hairless-midi for usb-midi comm and loopbe1 for virtual midi ports.

    Is there a way to send *both* data and audio at the same time through a *single* usb cable? I could just throw in a cheap usb soundcard, but that would mean using 2 usb cables at the same time.
     
  2. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,791
    1,103
    :confused: The audio is data, encoded serially.
     
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,388
    497
    Got a block diagram?
     
  4. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    Sure, send over a different pipe.
     
  5. stefan.54

    Thread Starter New Member

    Dec 26, 2015
    28
    4
    @shteii01 This would be a rough block diagram.

    I'm not much of a "connoisseur" of how usb stacks/pipelines work.
    Could you describe the bigger picture of how the arduino send midi messages and the laptop sends "audio" through the same cable at the same time?

    Thanks a lot!
     
  6. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,388
    497
    Ok.

    First problem.
    Like Alec said. Once you digitize the analog audio, it is not audio anymore. It is data. So, you feed analog audio to the ADC, what comes out of ADC? Data. For the sake of clear understanding let us call it Audio Data.

    Second problem.
    You want to send Audio Data and some other data over usb to pc. Fine. However, analog audio is going to be arriving to ADC continuously, ADC will digitize it continuously so you will have Audio Data collecting continuously, and you want to send it to pc. So there will be continuous stream of Audio Data from Arduino board to pc. Where does the other data fit in?
    The way to overcome this situation is that you will have to break the Audio Data and the other data into chunks, then send one chunk of Audio Data, end transmission of Audio Data, send chunk of other data, end transmission of other data, send chunk of Audio Data, and so on. So you will not be streaming anything, not Audio Data nor other data, live. However, now you need to figure out how big these chunks are going to be. Arduino board may or may not have enough RAM? to store your Audio Data and to store other data. So you might have to use external RAM to store your various data. Again, at this point I don't know how much RAM. You might have seen SD card readers used with Arduino boards. That is certainly an option, but from what I understand it is quiet slow. I don't do audio so I don't have accurate gauge of your needs. For audio I would think you would want transmission from Arduino board to pc to be in milliseconds. Meaning you record a few kilobytes? Transmit it to pc. Transmit other data to pc. A hundred milliseconds here, another hundred milliseconds there, it will build up over time so you need to store the Audio Data on a pc, build a buffer, then feed the stored Audio Data out of the pc so that audio perceived by listeners is continuous, without hick ups and skips.

    These are my thoughts on the topic thus far.
     
Loading...