Announcement

Collapse
No announcement yet.

OSCulator to Arduino Mega for triggering solenoids

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • OSCulator to Arduino Mega for triggering solenoids

    Hello,

    I'm trying to send MIDI data from OSCulator to my Arduino Mega through a serial port. Is this possible to do? I read some forum discussion from 10 years ago but it seems to not have continued. I can get the MIDI from Logic Pro X to correctly register into OSCulator, I just can't figure out how to send it from OSCulator to my Arduino Mega.

    Any ideas on how to do this?


    And in general, I just purchased OSCulator 3.0 and am having a difficult time! I'm a musician by trade and have little to no experience with coding and tinkering with tech in general. All of the documentation (manual, videos, etc) are for older versions and I can not understand what to do in OSCulator. Thanks in advance for any advise! Please let me know if you need more info from me to understand the situation.

  • #2
    Ok update, I found a solution if anyone else needs to solve this problem in the future! I had Chat GPT write me the following python script to create a bridge similar to "Hairless Bridge" that works on Windows.



    import serial
    import mido

    # Set up the serial connection to your Arduino
    # Replace '/dev/cu.usbmodem143401' with the correct port for your Arduino
    ser = serial.Serial('/dev/cu.usbmodem143401', 9600, timeout=1)

    # Set up the MIDI port
    # Use the name of the port you created in your IAC Driver, in this case, 'IAC Driver Output to Arduino'
    midi_port = mido.open_input('IAC Driver Output to Arduino')

    print("Sending MIDI messages to Arduino...")

    # Main loop to listen for MIDI messages
    try:
    for msg in midi_port:
    # Check if the message is a 'note on' or 'note off' message
    if msg.type == 'note_on' or msg.type == 'note_off':
    # Convert MIDI message to bytes and send over serial
    ser.write(msg.bytes())
    print("Sent:", msg)
    except KeyboardInterrupt:
    # Close the serial port when done
    ser.close()
    print("Closed MIDI and Serial connections.")

    # Use this to close the serial port if the loop exits without a keyboard interrupt
    ser.close()



    Running this in terminal I was able to send OSC messages from OSCulator into the serial port, which Arduino then could interpret. Here's an overview of the final version of the project...


    Logic Pro X (create midi instrument track and put in notes) ---> IAC Driver (create a port on the IAC Driver and in Logic make the MIDI Instrument's "MIDI Destination:" your newly created port) ---> OSCulator (the only thing you need to do is in the "Devices" tab select your IAC Driver you created under the "MIDI Input Ports" column) ---> Python script (script above, creates a bridge to pass the OSC messages) ---> Arduino Mega



    If anyone is trying to do something similar and have a hard time I'd be happy to give advise if I can.
    ?

    Comment

    Working...
    X