| Author |
Message |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
Posted: Thu Nov 30, 2006 6:02 pm Post subject:
Reverse engineering USB protocol, NM1 to G2 converter |
 |
|
Hello,
I just bought a brand spanking new G2X from www.novamusik.com for $2100 with a case. I'm really happy with the box though some of threads around here are dis-heartening about the lack of updates for the G2. As the unit stands, it is a very solid machine. I like it alot. I also run a Roland Fantom-X7, and a Korg Triton Pro-X. I was tired of the lack of "analog" features of samplers. Plus most of the sound design for samplers came down to using the Sine,Square,Triangle,Sawtooth waves anyways. Why not get a analog or modular system? Hence I got the G2X.
That said, I just wanted to let everyone here know I'm working on reverse engineering the USB protocol and creating a tool for convertion of NM1 to G2 patches. I'm an embedded linux developer for my company. I'm really a linux geek. This is main development platform. I actually have the Modular G2 Demo running under wine and it works great under linux. The problem is wine doesn't support running drivers within it (yet?). I also do alot of python (a scripting language) programming for prototyping, testing, and developing the systems we build at work. So, I have a python module called pyusb that allows me to script communication to a USB device (i.e. the G2). I also downloaded and installed a USB protocol capture utiliy called SnoopyPro that allows me to view the USB message passing from application to device. I've got alot already captured and have verified the communication with my python script to make sure the messages work. I am able to switch variations, select knob pages, activate slots, and assign keyboard, and set the focus all through the USB connection using python and pyusb only.
The other project I'm working on is a NM1 to G2 converter. I'm also writing this in python. My goal is to create an application that can be modified to dynamically create the convertion of NM1 modules to multiple G2 modules when necesary. I want it expandable to cover areas where the need to build a group of modules to match the NM1 module, it can be adjusted accordingly. Right now I'm working on reading in G2 patch and performance files. I started with the exellent web page: http://www.dewb.org/g2/pch2format.html that helped me get started but had some flaws in the format. It was missing most of the module categories so there is work to be done there. Next, I need to create a NM1 patch parsing utility using the NM1 documentation provided by BlueHell.
Mind you, most of my development is under linux as I don't develop software for Windows machines. I do the USB protocol capture though. The python applications will be portable and will run under Windows and Mac OSX. I can create stand alone executables that will run under Windows. So whatever I come up with, will be usable on all platforms. I will attempt to get that to work.
Sorry for being so long winded but I wanted you to know that I'm gonna try my best to get this stuff done. It's going to take awhile, especially because I have several other projects that require my attention that will take precedence for the next couple of months. I will still be hacking away though from time to time. Anyone who wants to help with a knowledge of python, USB, libusb, pyusb, G2 internals, NM1 internals is more then welcome to help. I can give you my scripts and USB captures. I'm trying hard to document my tests and results.
Let me know and thanks for listening.
qfingers |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Nov 30, 2006 6:05 pm Post subject:
|
 |
|
Sounds great! Keep us posted! _________________ Kassen |
|
|
Back to top
|
|
 |
glitched
Joined: Mar 25, 2006 Posts: 80 Location: phila., pa USA
|
Posted: Thu Nov 30, 2006 7:57 pm Post subject:
|
 |
|
Kudos to you!
This is great news considering that Clavia has all but abandoned the G2. (Why can't more Swedish electronic instrument companies be like Elektron? They are constantly developing and bug-fixing.)
I'll be watching this thread, as many others will, I'm sure.
-d |
|
|
Back to top
|
|
 |
jksuperstar

Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18
|
|
|
Back to top
|
|
 |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
Posted: Thu Nov 30, 2006 8:59 pm Post subject:
|
 |
|
It's over a year old and it has errors. I have fixed my parser to work correctly with the version 23 of the .pch2 file format. There is no document of the .prf2 files which I've mostly decoded. Alot of the information is also used in the USB protocol when adding modules to a patch, creating cable connections, etc.
One problem I noticed is that the values for frequency and time are different between the NM1 and the G2. The patch converter will require the "closest" match. I've got a way to get before I get there. First, I've got to get my parser to determine and handle all the module types of the G2. Then create a parser for the NM1 and all it's module types. Finally, create a table to map NM1 modules to G2 modules. This would include extra functions to create all the modules in the G2 to match the missing NM1 modules. I want to also add code to detect the cable routing to optimize the module creation for the G2 when functionality of a NM1 modules is not used.
qfingers |
|
|
Back to top
|
|
 |
dasz

Joined: Oct 16, 2004 Posts: 1644 Location: victoria, canada
Audio files: 29
G2 patch files: 56
|
Posted: Thu Nov 30, 2006 9:13 pm Post subject:
|
 |
|
qfingers, this is quite an undertaking and I wish you all the best in this project.
Once finished, your code could help in other areas where g2 has limitations - like keeping 2 g2's patches synchronized (so all the patches from one are sent to another) or being able to send sub patches to an existing patch (something along the lines of Init1 and Init2 but inserting modules into existing patches)
/Dasz |
|
|
Back to top
|
|
 |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
Posted: Thu Nov 30, 2006 9:27 pm Post subject:
|
 |
|
| dasz wrote: | qfingers, this is quite an undertaking and I wish you all the best in this project.
|
It is, but I've done things similar for the Fantom-X and Korg Triton for handling the files, patches, etc.
| dasz wrote: | Once finished, your code could help in other areas where g2 has limitations - like keeping 2 g2's patches synchronized (so all the patches from one are sent to another) or being able to send sub patches to an existing patch (something along the lines of Init1 and Init2 but inserting modules into existing patches)
|
I want to create a command line utility to do things like that. Things like: move, copy, delete patches and performances, display textual list of the current patch, performance, get and set parameters, load patches and performances, select editing pages and variations, query controller values. I can add functionality also for the "static parameters" wishlist item or at least something similar.
q |
|
|
Back to top
|
|
 |
dasz

Joined: Oct 16, 2004 Posts: 1644 Location: victoria, canada
Audio files: 29
G2 patch files: 56
|
Posted: Thu Nov 30, 2006 9:36 pm Post subject:
|
 |
|
| Quote: | | It is, but I've done things similar for the Fantom-X and Korg Triton for handling the files, patches, etc. |
That's great! It's time consuming for sure. When I wrote the Opcode Revolve sequencer, we reverse engineered both Rebirth file format twice (two versions).
One could create a gui for your command line application ... I wonder if one could use the USB port at the same time as the g2 editor?
/Dasz |
|
|
Back to top
|
|
 |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
Posted: Thu Nov 30, 2006 9:58 pm Post subject:
|
 |
|
| dasz wrote: | One could create a gui for your command line application ... I wonder if one could use the USB port at the same time as the g2 editor?
/Dasz |
My philosophy is to create GUI wrappers around command line utilities. It separates functionality and allows automation. I can actually take some of the messages received from the G2 to control other applications (at least under linux) and create MIDI messages from them. With a computer tied to the G2, I was thinking of creating a program to allow one dial (module parameter) to select and change groups of 8 knob pages to allow many more then 120 knob settings but 1000 or more. Something like a switch module so the names can be displayed and updated for all the different pages. Since the system is tied to a computer, there are all sorts of possibilities. I'm just suprised someone else hasn't done this yet. If Clavia published the specs on this stuff, the sytem would be much more received. Don't get me wrong, they created a great solid product. I would like specifications of the communication protocols and file formats. This would be enough to create a set of programs that will make the G2's much more useful and integraded into one's setup. My hope is that my applications will keep the G2 platform alive for a long time and perhaps Clavia see what is possible and provide the "real" documenation so my programs work perfectly with the G2.
As far as sharing the USB port, it can't be shared. There is too much interaction from the program to the synth. You might be able to send messages (not sure if that is even possible) to the synth. I haven't checked all the USB messages received. I'm hoping the key presses and releases are sent. I can use that to create a pseudo MIDI interface that is input only. It may be useful though if the G2 sends key press information that can be captured and send in another format like a MIDI message.
q |
|
|
Back to top
|
|
 |
dasz

Joined: Oct 16, 2004 Posts: 1644 Location: victoria, canada
Audio files: 29
G2 patch files: 56
|
Posted: Thu Nov 30, 2006 10:24 pm Post subject:
|
 |
|
I've always preferred COM/dll's - you can do this such as callbacks, etc ... but I've always done windows devt. I hope your app will work on windows and a mac?
| Quote: |
As far as sharing the USB port, it can't be shared. There is too much interaction from the program to the synth. You might be able to send messages (not sure if that is even possible) to the synth. I haven't checked all the USB messages received. I'm hoping the key presses and releases are sent. I can use that to create a pseudo MIDI interface that is input only. It may be useful though if the G2 sends key press information that can be captured and send in another format like a MIDI message. |
In that case we could turn the editor off via this app whenever interaction is needed. so your app you could launch and turn off the editor whenever it needs.
/Dasz |
|
|
Back to top
|
|
 |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
Posted: Thu Nov 30, 2006 11:06 pm Post subject:
|
 |
|
| dasz wrote: | I've always preferred COM/dll's - you can do this such as callbacks, etc ... but I've always done windows devt. I hope your app will work on windows and a mac?
In that case we could turn the editor off via this app whenever interaction is needed. so your app you could launch and turn off the editor whenever it needs.
/Dasz |
All my code will probably be in python. I think there is a port of libusb for windows which can be used for communication to the G2 (or any usb device), but I'm not sure about a mac as I have zero access to osx. I will provide the source code, so other programs could (and hopefully will) be written. Check python out at http://www.python.org. By the way, I've written python applications that stream 114MB/sec over a gigabit ethernet link with no drops in data using UDP and multicast. It is a scripting language but can be optimized to perform quite well when coded correctly. Just a side note.
q |
|
|
Back to top
|
|
 |
jksuperstar

Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18
|
Posted: Fri Dec 01, 2006 12:14 am Post subject:
|
 |
|
G2 editor on Linux, Yahoo!! Single editor for NM1 and G2, Yahoo!!! Macros, here we come!! YahooO!!
Oh, one can dream, right? Tools like these certainly open ALOT of doors. GREAT effort, and I'd offer any help I can that's useful. I'm not a linux guru, but do expect to fully switch over in the next year, and I've put together my own live CD (hacked from others) and continue this effort.
However, I know no python, but this seems like a good reason to learn it. I know Python is powerful, but i've just not had a reason to use it yet. |
|
|
Back to top
|
|
 |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24492 Location: The Netherlands, Enschede
Audio files: 298
G2 patch files: 320
|
Posted: Fri Dec 01, 2006 4:22 am Post subject:
|
 |
|
Don't have time now, but also see : http://www.iaf.nl/Users/BlueHell/html/nm-open/nm-open-g2info.htm
Christian Schneider who made the Nomad NM Classic thingy will be interested as well I guess. Please do a seach for that on this forum.
Later, _________________ Jan
also .. could someone please turn down the thermostat a bit.
 |
|
|
Back to top
|
|
 |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
Posted: Fri Dec 01, 2006 7:01 am Post subject:
|
 |
|
Cool. The module and parameter lists are a time saver. Thank you!!!
That should speed the process. Now what else is needed is the frequencies and times of various parameters as they do not match the NM1's frequencies and times. But what you have there is more then enough to move forward.
I did look at Nomad. My only question is how java communicates with USB. If that is a solvable problem, I'm sure the editor can be updated to handle the G2 as well. Currently there are alot of unknown messages passed. Also several in the patch files, there are holes in various sections. Hopefully they can be deciphered. I'm going to parse all available patches and performances I can find on the net and look at the differences in those areas. This may point to the unknown sections and values within the sections.
Again thanks for the info. It will speed the process.
q |
|
|
Back to top
|
|
 |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24492 Location: The Netherlands, Enschede
Audio files: 298
G2 patch files: 320
|
Posted: Fri Dec 01, 2006 2:38 pm Post subject:
|
 |
|
Ok have time now, on the forom qfingers.
On actualy reading the thread I now see most things to be said already have been.
Yes an exact description of parameter values and their effects would be needed as well in the future. Guess I just didn't have such high ambitions in mind when I compilated the parameter stuff, but maybe later, this project would be a good excuse to put some more time in it
Maybe a good warming up project for you would be http://electro-music.com/forum/topic-14727.html , but whatever you choose to do or not do, please keep us posted ! _________________ Jan
also .. could someone please turn down the thermostat a bit.
 |
|
|
Back to top
|
|
 |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
Posted: Fri Dec 01, 2006 2:54 pm Post subject:
|
 |
|
I don't have an NM1 so I can't be of much help.
But, I'm pretty well along with the USB stuff and don't really have time to work on yet another project. The information you gave me before is enough to keep me going for a while. I've already parsed your module_table.txt and param_table.txt to something I can use. This will help with module list and module parameters section of the .pch2 files. The nice thing is that the USB protocol uses the same section format as the .pch2 and .prf2 files so it's all applicable. This will help deciphering the bits I don't understand yet. This is enough for me. I'll keep you posted...
q |
|
|
Back to top
|
|
 |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24492 Location: The Netherlands, Enschede
Audio files: 298
G2 patch files: 320
|
Posted: Fri Dec 01, 2006 2:59 pm Post subject:
|
 |
|
| qfingers wrote: |
I don't have an NM1 so I can't be of much help. | Too bad ... too bad ... you'll need one sooner or later
| Quote: | | The nice thing is that the USB protocol uses the same section format as the .pch2 and .prf2 files so it's all applicable. |
Just as the MIDI patch dumps do then I guess ?
Wouldn't be surprised BTW when individual parameter edit commands would be similar to what is used for the NM Classic, but what do I know ... _________________ Jan
also .. could someone please turn down the thermostat a bit.
 |
|
|
Back to top
|
|
 |
Afro88

Joined: Jun 20, 2004 Posts: 701 Location: Brisbane, Australia
Audio files: 12
G2 patch files: 79
|
Posted: Fri Dec 01, 2006 6:44 pm Post subject:
|
 |
|
Keep up the good work qfingers!
I like the idea of creating a midi driver from the usb interface, eliminating the need for 2 midi cables and a midi interface. Also, I would imagine it would be more stable during periods of high cc activity too.
A pch to pch2 converter... imo that's a bit of a pipe dream, but if you get it to work it would be a fantastic and extremely valuable acheivement - thousands of patches will be opened up for use instantly!
And the knob expander app would be killer too! |
|
|
Back to top
|
|
 |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
Posted: Fri Dec 01, 2006 9:29 pm Post subject:
|
 |
|
| Afro88 wrote: | Keep up the good work qfingers!
I like the idea of creating a midi driver from the usb interface, eliminating the need for 2 midi cables and a midi interface. Also, I would imagine it would be more stable during periods of high cc activity too.
|
Well, I'm not really sure I can get this to work because it relies on the fact that the key presses and key releases are sent from the G2. If it doesn't there is no chance. If there is, you still need a MIDI interface and a piece of software that would inject the message to a MIDI interface/sub-system.
| Quote: |
A pch to pch2 converter... imo that's a bit of a pipe dream, but if you get it to work it would be a fantastic and extremely valuable acheivement - thousands of patches will be opened up for use instantly!
|
I'm not looking for a 100% solution. That is probably not possible. But with around 20000 patches for the NM1, even a 25% solution would be nice. I hoping for 50% to 90%. Plus at least the hope of slight modifications. I want the software to at least point out where things need corrections.
| Quote: | | And the knob expander app would be killer too! |
We see how that one turns out.
q |
|
|
Back to top
|
|
 |
cappy2112

Joined: Dec 24, 2004 Posts: 2498 Location: San Jose, California
Audio files: 2
G2 patch files: 1
|
Posted: Sun Dec 03, 2006 11:10 pm Post subject:
|
 |
|
| dasz wrote: | | I've always preferred COM/dll's - you can do this such as callbacks, etc ... but I've always done windows devt. I hope your app will work on windows and a mac? |
Python does have windows extensions which support COM very well, and it's actively supported.
However, COM isn't a portable interface, and the author mentioned the utility must be portable |
|
|
Back to top
|
|
 |
3phase

Joined: Jul 27, 2004 Posts: 1189 Location: Berlin
Audio files: 13
G2 patch files: 141
|
Posted: Mon Dec 04, 2006 12:17 am Post subject:
|
 |
|
| qfingers wrote: |
I'm not looking for a 100% solution. That is probably not possible. But with around 20000 patches for the NM1, even a 25% solution would be nice. I hoping for 50% to 90%. Plus at least the hope of slight modifications. I want the software to at least point out where things need corrections.
q |
It would be beneficial allready when only the basic structure gets ported..
would safe hours of work for conversion trys..especially when the software allready corrects some missmatchings in parameter settings and levels...
The colors of the G2 editor can be helpfull to mark areas where the converter sees itself getting in trouble...
Maybe critical modules for conversion can be replaced by free definable complete buildingblocks in the G2...
The spectral oscilator for example..there are patches where the simple shape osc can easily do the jobs while ther are otheres where you can do what you want on the G2 and never get it sounding wright...
So just exchanging the spectral oscilator by the shape osc would only do the job in 50% cases while exanching the spectral osc by an expensiv building block is just not necessary than...
Would be maybe nice if there would be some kind of dialog with the converter where you quickly can try a few conversion options and just decide by ear which one sounds best to keep for further fine tuning.
A bit like the mutator.
Anyway...
hope you succed with this interesting projekt.
regards
Sven |
|
|
Back to top
|
|
 |
dasz

Joined: Oct 16, 2004 Posts: 1644 Location: victoria, canada
Audio files: 29
G2 patch files: 56
|
Posted: Mon Dec 04, 2006 9:26 am Post subject:
|
 |
|
| cappy2112 wrote: |
Python does have windows extensions which support COM very well, and it's actively supported. |
That's good.
| cappy2112 wrote: |
However, COM isn't a portable interface, and the author mentioned the utility must be portable |
Of course. I was thinking only of myself there. providing nice extensions can make building UI's for Windows very easy. OSX/Linux is more involved (depending on the UI toolkit).
/Dasz |
|
|
Back to top
|
|
 |
qfingers
Joined: Nov 16, 2006 Posts: 186 Location: Tucson, AZ
G2 patch files: 2
|
|
|
Back to top
|
|
 |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24492 Location: The Netherlands, Enschede
Audio files: 298
G2 patch files: 320
|
Posted: Tue Dec 05, 2006 7:22 pm Post subject:
|
 |
|
...  _________________ Jan
also .. could someone please turn down the thermostat a bit.
 |
|
|
Back to top
|
|
 |
cappy2112

Joined: Dec 24, 2004 Posts: 2498 Location: San Jose, California
Audio files: 2
G2 patch files: 1
|
Posted: Tue Dec 05, 2006 8:06 pm Post subject:
Re: Update |
 |
|
| Quote: |
I had to change the extension to .py.txt because the forum doesn't allow .py extensions (why????). |
Because it's an executable file and could be processed by the web server and executed ?? |
|
|
Back to top
|
|
 |
|