Author Topic: Converting an old Roland GR-1 to USB  (Read 14801 times)

0 Members and 1 Guest are viewing this topic.

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Converting an old Roland GR-1 to USB
« on: September 10, 2016, 12:56:59 pm »
Hey gang, I've recently got a second hand Roland MIDI guitar pickup (GK-2) and a GR-1 processor which does a couple of things - converts the analog output of the pickup (which is just 6 small humbucker pickups, one for each string) to MIDI messages, and also has a synthesizer inside of it. It only has analog outputs for the synthesized audio, and only MIDI DIN-5 connectors for the MIDI data.






I'd like to add an USB port to it, with some micro which would take the digital audio from before the DAC (uPD6376GS), and announce itself as a USB sound card and MIDI device. There is a tiny bit of space left on the back pannel for a USB type B port.

Anyway, my question is how would I do this with least hardware hassle - ie, choose a small board with the USB port on it, maybe an Arduino or derivative (I've successfully used a Pololu A-star 32U4 for USB MIDI before), wire LRCK, CLK and SI/LSI from the DAC, and then the MIDI stuff as well, then after the wiring is done, I can just code the firmware. There's +5V available, but also +7V and -7V, so perhaps I can skip the power supply part. I'd also like to use a USB type B instead of microUSB, simply because it's physically more robust, or at least I feel like it is.

I don't know the frequency of the clock pin yet, the datasheet says something about 400khz max for the DAC, but it's likely around 44100 Hz. The synthesis chip uses a ROM for the samples, so I'm thinking they'd be using a limited sample rate just to efficiently use the space.

GR-1 Service Manual: https://www.dropbox.com/s/dw4ou57kfz9wvqd/ROLAND_GR-1_SERVICE_NOTES.pdf?dl=0
GR-1 Owner's Manual: https://www.dropbox.com/s/qbidxhtcaor5sng/GR-1_OM.pdf?dl=0
uPD6376GS datasheet: https://www.dropbox.com/s/cyhon0aq1s6okph/uPD6376GS.pdf?dl=0
GK-2 Owner's Manual: https://www.dropbox.com/s/80i6ngj6s5t5s1q/GK-2_OM.pdf?dl=0

Here is the DAC:


Here is the MIDI stuff:


Here's the back of the thing, with a mark where I think the USB port would fit:
Ports are DC IN 9V/1.5A, power switch, MIDI OUT, MIDI IN, GK-2 13-pin input, Volume pedal input, custom pedal input (these are both just foot pedals with potentiometers, afaik), guitar out (simply takes the regular guitar output so you only use one cable), guitar return L and R, MIX OUT R and L/mono, phones.

« Last Edit: September 10, 2016, 01:14:35 pm by vampi-the-frog »
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1610
  • Country: gb
Re: Converting an old Roland GR-1 to USB
« Reply #1 on: September 10, 2016, 04:08:15 pm »
No replies? I'll give it a bash :D

As you may have guessed by googling, USB audio is a hotly debated topic - mostly because of unrealistic expectations (latency) from 'audiophiles' and the bad reputation of very low end products.  But it can be done, either with a stock 'chip that does it for you', or using a micro with a USB peripheral and I2S capability.  The CM108 by 'C-media' is cheap, cheerful, and does the job.  I haven't seen these devices available to buy from distributors, but so many cheap 'USB soundcard' plug in dongles are based on it you can pick these up from Amazon for $2:

https://www.amazon.co.uk/Dynamode-USB-2-0-Sound-Card/dp/B0010JP9CY

It accepts I2S but specifically at either 48kHz or 44.1kHz (the chip has on board PLL to convert the 12MHz used for USB to 12.288/11.2896).  Datasheet here: http://www.qsl.net/om3cph/sb/CM108_DataSheet_v1.6.pdf

A quick fudge would be to just wire the audio out of your MIDI thing to the audio in (re-sampling using its build-in ADC), but depending on the sample rate of the DAC, if they match you should be able to just hooked it up with I2S.

As for having MIDI *and* audio via the same USB, I haven't seen any devices that will do that for you, so you will have to roll your own.  There are app notes from ST and microchip on how to do this using the STM32, and PIC32 but it is very involved - I spent a month in my spare time making a half decent USB ADC/DAC from a PIC24 using asynchronous transport, mostly because windows drivers only like to use isochronous.  USB audio also uses up quite a bit of USB bandwidth, mostly because it's real-time, so cannot have large buffers.  The same goes for MIDI, the actual through-put isn't that much, but to reduce the latency to a low level (<30ms) you have to send small packets regularly, which isn't an efficient use of the bus.

Another cheapy way to do it would be to use a MIDI - USB converter, and a audio-USB (like the one linked above) and have a cheap 4-port USB hub.  Effectively meaning you have one USB cable, with two devices.  Its not an elegant solution, but would still be rather small, perhaps able to fit into the housing and its also rather cheap.

I suspect you will have latency issues whatever you do, I remember a friend had one of these and there was noticeable latency between plucking a string and a 'sound' being made, add to that the 10-50ms from USB, soundcard playback latency etc.. and it can get annoying.

Hopefully some food for thought!
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #2 on: September 10, 2016, 04:55:00 pm »
From the CM108 datasheet, it does seem it has very similar input pins for the serial data, ADSCLK (ADC I2S Serial Clock), ADLRCK (ADC I2S Left / Right Clock) and SDIN (ADC I2S Data Input). I'll have to measure the actual sample rate somehow. The GR-1 service manual doesn't seem to say anything about its value. The chip that feeds the DAC has a 20MHz clock input, so I'm thinking it's going to be a subdivision of that.

Food for thought indeed.
« Last Edit: September 10, 2016, 04:56:31 pm by vampi-the-frog »
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #3 on: September 13, 2016, 09:19:53 pm »
I am looking at Arduino Teensy, it seems to have a powerful enough controller, and it just might be enough for my needs. So, a record-only sound card, with an unknown sample rate (I estimate about 25kHz or 32kHz, haven't been able to measure yet), and MIDI in and out ports, both on USB. I also like the look of this olimex board, simply because of the USB type B port.

There's also a dev library for USB devices, STM32Cube, which seems to make it easy to code such things.

Also,

Anyone experienced with this?
« Last Edit: September 13, 2016, 09:30:09 pm by vampi-the-frog »
 

Online Someone

  • Super Contributor
  • ***
  • Posts: 4510
  • Country: au
    • send complaints here
Re: Converting an old Roland GR-1 to USB
« Reply #4 on: September 14, 2016, 12:19:52 am »
So, a record-only sound card, with an unknown sample rate (I estimate about 25kHz or 32kHz, haven't been able to measure yet), and MIDI in and out ports, both on USB.
The sample rate will be your problem, almost all "sound cards" want to be the master clock. Trying to synchronise software with the internal word clock of an arbitrary device (your GR-1 here) is quite a challenge, or you'll need use an asynchronous sample rate convertor to allow both devices to run at their own sample rates.
 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: Converting an old Roland GR-1 to USB
« Reply #5 on: September 14, 2016, 06:08:27 am »
If you want to do a custom job then perhaps the Cypress PSoC5 is something you want to look at. The dev-board is only about 10$...

I have the Roland  VG-99 ;-)
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 
The following users thanked this post: alexanderbrevig

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #6 on: September 14, 2016, 07:03:31 am »
almost all "sound cards" want to be the master clock

Can you elaborate on that a bit please?

I was thinking I could use the DAC's clock as an interrupt, then build a buffer and send it when it's full. I don't care if there's much latency at this point, I just want the digital data.

If you want to do a custom job then perhaps the Cypress PSoC5 is something you want to look at. The dev-board is only about 10$...

I have the Roland  VG-99 ;-)

Quite interesting dev board. It really looks like I'll have to get a bunch of them and experiment.

Really nice gear too! I'd like to get the Boss GP-10 too when I can afford it, it seems to have similar functionality to VG-99. Can you record audio + MIDI through the USB port?
« Last Edit: September 14, 2016, 07:11:19 am by vampi-the-frog »
 

Offline casinada

  • Frequent Contributor
  • **
  • Posts: 599
  • Country: us
Re: Converting an old Roland GR-1 to USB
« Reply #7 on: September 14, 2016, 07:22:50 am »
May be you should try to get one of the Midi to USB adapters:
http://www.m-audio.com/products/view/midisport-1x1
http://www.m-audio.com/products/view/uno
 :)
 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: Converting an old Roland GR-1 to USB
« Reply #8 on: September 14, 2016, 07:34:42 am »
Can you record audio + MIDI through the USB port?

Not sure about MIDI, but I have recorded from it over USB. I would be really surprised if MIDI wouldn't work over USB.

I am not familiar with the Boss GP-10 - it looks more for live playing and VG-99 is (IMO) more for studio work.
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1610
  • Country: gb
Re: Converting an old Roland GR-1 to USB
« Reply #9 on: September 14, 2016, 04:38:21 pm »
There's several grey areas here that I think need to be cleared up.  Firstly, just sending bytes, that just so happen to be digital audio samples, over USB, isn't the same as USB audio.  If you want your PC/mac to pick the USB devices up as an audio device, then it needs to enumerate as such and adhere to certain restrictions that will govern how it works - including sample rate, bit depth, feedback endpoints to tell the PC how many samples its sending (so it can calculate the sample rate, and convert it to your playback sample rate accordingly). 

Similarly a MIDI device, if you want your apps to pick up the midi messages, must be a USB MIDI device class.  One can of course have several devices on one bus, but is very involved. 

If your goal is just to use USB to 'get data' from it, then you can indeed use a teensy/STM32 to read bytes from the I2S, and a UART for the MIDI, and just package them up and send them over USB as a HID device - but that won't help at the other end, its just 'bytes'.  You could easily write an application that picks up these bytes, and writes to a *wav and a MIDI file but they will only be available after you've stopped recording. 

Apologies if I was wrong in my reply, I had assumed you wanted to make something that means when you plug it into your PC via USB, it appears as both an audio device (a recording device) and a MIDI device (for using VST plugins, cubase, logic pro etc..).  I have seen both DIY USB soundcards, and DIY USB MIDI interfaces, but not a project that merges the two.  It can of course be done, one can buy interfaces with audio in/out and MIDI in/out in one box, but they're about £110-150.
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Converting an old Roland GR-1 to USB
« Reply #10 on: September 14, 2016, 05:12:19 pm »
+1 to what Buriedcode said

Quote
There's also a dev library for USB devices, STM32Cube, which seems to make it easy to code such things.
A suitable STM32 can do what you want but there will be an awful lot of code to put together.
ST do provide sample code/project for direct audio sampling via built in ADC
I am not aware of any sample code/project for MIDI from ST or other.
ST do provide a sample project for USB Composite device, that is a USB device with more than 1 USB endpoint device.
ST do provide a sample project for USB Audio but NOT MIDI.

I do not know where the I2S came into the conversation, but again STM32 can do I2S, it is buried in the SPI controller I think.
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #11 on: September 14, 2016, 05:29:04 pm »
It looks like STM32Cube supports the USB Audio class (page 43), so that's what I'm planning to use.

I can't figure out whether I need a programmer for the STM32-H103, or if I can just use the USB port for programming it. Anyway, the JTAG programmer costs more than the dev board :palm: so I'm trying to figure out how to program it.

It's ok if I can't do the MIDI part, I can use a separate usb to MIDI cheapy device, but it would be cool if I can do both.

EDIT: there are USB MIDI libraries for Arduino, and they look pretty thin. I'm a programmer in real life, so coding the USB MIDI part is not really an issue.

Also, nice cleanly recorded song, obi.
« Last Edit: September 14, 2016, 06:53:33 pm by vampi-the-frog »
 

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Converting an old Roland GR-1 to USB
« Reply #12 on: September 14, 2016, 07:22:41 pm »
Yes, it looks like the Olimex board requires a Jtag debugger/programmer.

Try looking at the St Discovery or Disco range of dev/eval boards.
They have on board St-link debugger/programmer and they are amazingly cheap.

http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-discovery-kits/stm32vldiscovery.html
 

Online Someone

  • Super Contributor
  • ***
  • Posts: 4510
  • Country: au
    • send complaints here
Re: Converting an old Roland GR-1 to USB
« Reply #13 on: September 15, 2016, 12:16:30 am »
almost all "sound cards" want to be the master clock

Can you elaborate on that a bit please?

I was thinking I could use the DAC's clock as an interrupt, then build a buffer and send it when it's full. I don't care if there's much latency at this point, I just want the digital data.
Then how will your handle the data from there? As soon as you want to hear that sound coming in at your arbitrary sample rate you'll need to either provide an audio output at the same sample rate or filter it to the new sample rate (asynchronous sample rate convertor). Audio interfaces don't offer completely free sample rate options, few even provide adjustable sample rates (beyond a few fixed standard rates such as 8/16/32/44.1/48/96 kHz), fewer again will accept an external word clock.
https://en.wikipedia.org/wiki/Word_clock
The computer software wants to operate at a single sample rate, so usually all outside sources are either slaved to the computer or brought in through asynchronous sample rate convertors. A lot of the complexity is hidden in editing where all the processing can be done offline (render caches etc) and played at reduced quality until that catches up. Doing everything in realtime is much harder.

Its a complicated and large topic:
http://www.soundonsound.com/techniques/does-your-studio-need-digital-master-clock
Quote
When combining or interconnecting digital signals from different equipment or sources, it's vital that the audio samples from each device arrive at exactly the same time, so that their data can be mixed together or otherwise processed. If they don't arrive together, samples from some sources will be missed, and clicks or glitches may be heard. The golden rule is that one device has to be declared the 'master' clock source for the whole system, and everything else must be 'slaved' to that clock source to ensure that everything generates samples at exactly the same time and rate.
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #14 on: September 15, 2016, 05:02:28 pm »
Yo, I've ordered the dev boards, I'll let you guys know on my progress.
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #15 on: September 21, 2016, 04:20:45 pm »
Aight, here's an update.

The dev boards have arrived, it's a STM32VLDISCOVERY board, which has an on-board ST-Link, and 3 Olimex STM32-H103 boards. I managed to wire the on-board programmer from the Discovery board to an Olimex board, and managed to get blinky led working.

I generated the code with STM32CubeMX, and selected USB Audio Interface in there, but it seems I have to do some magic in the main loop. I'm now looking for a working example.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Converting an old Roland GR-1 to USB
« Reply #16 on: September 21, 2016, 04:28:59 pm »
You can use USB to MIDI chipsets like CH345 to bridge between USB and MIDI. Then find a good DAW that can make use of it.
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #17 on: September 21, 2016, 06:25:50 pm »
Well I managed to use this setup once, but now Keil is saying "No target connected" and it's saying the same thing when I connect it to the onboard STM32 as well, so it looks like it's busted for some reason. I managed to program 2 of the Olimex boards once, to get the blinky led program running, but then it started generating this error. The led is still blinky, but it's not programming or detecting it. I'm using SWD.

I'll get back when I fix it, I guess.

EDIT: aparently it has something to do with the reset pin, I'm still getting the hang of this.
« Last Edit: September 21, 2016, 07:07:06 pm by vampi-the-frog »
 

Offline pepelevamp

  • Regular Contributor
  • *
  • Posts: 101
  • Country: nz
Re: Converting an old Roland GR-1 to USB
« Reply #18 on: September 21, 2016, 06:53:11 pm »
Hi dude. Your project is similar to mine.

Ya know there's nothing wrong with having it register as two USB devices. A USB soundcard and a USB MIDI controller. You can run them over the same cable by putting in a little USB hub.

I wired up a vintage telephone with a USB soundcard and an arduino inside its housing with a passive USB hub. All cheap electronics, but it works. The arduino even has enough guts to ring the bell on its own. It has one USB cable that goes to my PC. Now I can talk on Skype with it, and I can make it ring at will & tell when its off-hook etc.
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #19 on: September 21, 2016, 08:26:33 pm »
I wired up a vintage telephone with a USB

It ain't easy bein' cheesy!
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #20 on: September 28, 2016, 04:51:40 pm »
Alright, I managed to probe the DAC with a scope, I am seeing a 5MHz clock, which is 1/4 of the 20MHz clock that goes into the sound generator chip. The L/R signal (pin 13 of the uPD6376GS) seems to be about 65KHz, I'll assume it's a power of two, so 65536 Hz. I can't measure too precisely, it's an analog scope. However, the 5MHz clock seems to come in bursts of 48 cycles spaced apart just as the 65KHz L/R signal, so I assume that means it's loading up the value into the DAC at a faster speed than the actual sampling rate, which is ok, since the DAC probably holds the value until a new one is loaded. I have doubts that the sampling rate is 65536 Hz, so it's probably half of that, 32768Hz. I don't know how it divides the 20MHz to 65536Hz, the furthest I can simplify it is 78125/128. Either that or it's actually 64000 Hz, which simplifies to 625/2, or 32000 which simplifies to a division by 625.

I'll do some more probing with a logic probe, when it arrives.
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1610
  • Country: gb
Re: Converting an old Roland GR-1 to USB
« Reply #21 on: September 28, 2016, 11:05:00 pm »
Heres the datasheet for the DAC.

http://pdf.datasheetcatalog.com/datasheet/nec/UPD6376GS.pdf

I doubt its a '65536Hz' sample rate, you're thinking multiples of 2, not divisions of the clock :) With that said, it doesn't have to be a simple division of the clock because as you rightly pointed out, the 'bit clock' and 'LR clock' don't have to have to be related by a simple division factor (but they should come from the same source), as long as the sample bits are clocked in before the next LRCK edge, it stores that in its shift register.  This is handy and I've used it to made fairly high quality sound generators from an 8-bit micro, sending out samples over SPI in fast bursts, and manually bit-banging the LRCLK. Either way I suspect its a non standard sample rate, as it looks rather old  and was only ever meant to just output analogue - no need to stick to a standard 44.1/32/48 to interface with S/PDIF equipment.

I still say you would be better off resampling using a USB soundcard with the audio out tied to the soundcards line-in.  Whilst its nice and neat, and possibly more interesting to sniff the bus and collect bytes, getting those to your PC via USB that the PC will recognize as 'audio' will most likely require digital sample rate conversion which opens up a whole can of worms.
 

Offline firehopper

  • Frequent Contributor
  • **
  • Posts: 408
  • Country: us
Re: Converting an old Roland GR-1 to USB
« Reply #22 on: September 28, 2016, 11:26:07 pm »
why not use a new teensy 3.6? it can run at up to 240 mhz, plus has 2 dac channels, and can act as usb hosts for what ever you program.
 

Offline vampi-the-frogTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ro
Re: Converting an old Roland GR-1 to USB
« Reply #23 on: September 29, 2016, 09:59:22 am »
Just a few quick notes:

- wow, the forum looks really good on mobile, really readable and usable!
- it seems 32000 is a standard sample rate, from what some have said, and it also seems really close to my measured rate, so hopefully that'll be the case once I manage to get some more precise measurements, and it might simplify things.
- so far I've managed to get one of the STM32 dev boards to act like a HID mouse, it's a lot harder than Arduino programming, lots of libraries and drivers and middlewares and code generators and IDEs and programmer devices and all that, so it'll take a while to wrap my head around it.
- I had expected the code generated from STM32Cube to be immediately functional as a dummy USB device, but that is not the case, and the examples one finds are using different versions of libraries and there is a lot of code noise that I'm still wading through.
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1610
  • Country: gb
Re: Converting an old Roland GR-1 to USB
« Reply #24 on: September 29, 2016, 10:18:00 am »
Depends on what you mean by 'dummy device'.  You can't simply import a generic USB library and decide whatever device it should be (HID, mass storage, audio class etc..) because they all operate differently. And yes, even though there are many libraries to help, implementing any USB device is not trivial, if you can find a USB audio class library for the STM32, then of course that would be the way to go - modifying it as you need.

If the sample rate is 32kHz you may be in luck, as this is often supported by software, and certainly by the USB audio spec.   But unless there's a 8.192/16.384MHz xtal in there, it is more likely to be 31.25kHz as this is can easily be derived from a 4,8 or 16MHz clock - and its also the baud for the MIDI.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf