Making my own application for my USB MIDI device - usb

I want to try and make my own application for my Novation Nocturn, which is a USB DJ controller surface. The application software interacts with it to send out MIDI messages to software like Traktor, Ableton and Cubase.
I'm aware of libusb, but that's as far as I've got. I've successfully installed it to interact with my device but stopped there.
I'm after some suitable reading material basically. USB specs, MIDI specs and such. If I'm honest the full USB 2.0 spec looks like it holds loads of stuff I don't need.
Just looking for something interesting to do now that I've finished my degree (Computer Science). My current programming knowledge is C++ and mainly C#.
Could do with some direction on how to get stuck into this task.
edit:
Update to include some info from the Device Manager on the Nocturn.
Hardware IDs:
USB\VID_1235&PID_000A&REV_0009
USB\VID_1235&PID_000A
Compatible IDs:
USB\Class_FF&SubClass_00&Prot_00
USB\Class_FF&SubClass_00
USB\Class_FF
Device Class:
MEDIA

USB MIDI is probably one abstraction layer lower than you want to deal with. I'd suggest finding a good MIDI framework and interacting with the device via MIDI instead.
For C++, Juce is probably the way to go, as you didn't mention a target platform or any other specific requirements.

If you want to go the .NET route, the easiest way to get started is with the C# MIDI Toolkit code:
http://www.codeproject.com/KB/audio-video/MIDIToolkit.aspx
In there, you'll find all the basics for opening an device, reading input, and writing output. Alternatively, NAudio has some MIDI classes, but they are somewhat incomplete.
As you develop, you'll want a reference for the MIDI spec handy.
A tool that you will find invaluable is MIDI-OX. In fact, I suggest that before you start coding, you fire up MIDI-OX and use it to sniff the messages coming from the Novation. It will give you a good idea of what the Novation sends. You can use it in conjunction with MIDI Yoke (a configurable virtual MIDI port) to insert itself between the Novation, and Ableton Live (or whatever software you normally use with your Novation) so you can see all of the messages in normal use.

Done... Kidding, but I've started on this in Python - I personally want linux support. I am teaching myself python, but I only dabble in programming.
You can see basic functionality at https://github.com/dewert/nocturn-linux-midi. The guy who reverse engineered it (i.e. the leap I wouldn't have been able to make myself) doesn't seem to be doing any more with it. His code is at https://github.com/timoahummel/nocturn-game
I am using PyPortMIDI and PyUSB, both of which I believe are wrappers for the C equivalents. I think this is all ok on Windows, but haven't tried.
What is currently on my github is crap, but it is proof-of-concept. I'm working on doing it properly now, with threading and proper configuration options.

The driver for the Nocturn makes it appear to system as a MIDI device, even though it isn't a USB MIDI device at the hardware level. The Automap software works entirely at the MIDI level, receiving MIDI instructions and sending different instructions in response - it is separate from the driver and not neccesary.
Alternatively, look at https://github.com/timoahummel/nocturn-game for an example of talking to it directly over USB from Python. You can probably port this to another language with libusb bindings.

Old thread, but I've just recently started looking into this.
I had a look at the Python application that dewert has written. Interestingly, it turns out that the data that the Nocturn emits is in fact MIDI, although it doesn't register itself as a USB MIDI device.
But looking at the actual data coming from the device, it actually emits control change messages (0xB0 controller value) for everything. Also the control commands that are sent to it are also control change messages, albeit only the data bytes, as the Nocturn seems to support MIDI running status (i.e. when sending multiple control change messages, it is not necessary to repeat the data byte).
Indeed, the looking at the magical initialization data it is actually just a bunch of control changes: it starts with 0xb0 and from there on the data comes in twos. For instance the last two bytes in the init string are 0x7f 0x00 which simply turn off the LED for the rightmost forward button. (There is something subtle happening as a result of the initialization being sent though, as the Nocturn sometimes emits some messages which appear to be some form of timeout events, and that behavior changes depending on whether the initialization string has been sent or not.)
Using MIDI-like messages makes sense, as Novation would be well aware of the MIDI protocol, so it would be easiest for them to use it for the communication even if the device is not strictly a MIDI device.
Note though that the incrementors just send the values 1 or 127, i.e. +1 or -1 step, so even with some trivial mapping software it's not really useful as it is. (Actually, if turned quickly, one can get 3 or 125 for instance, with the 125 corresponding to -3.) The only controller which sends a continuous value is the slider, which emits an 8 bit value when moved.

I suppose you'll want to know about USB classes in general and USB MIDI class in particular. The latter is the best what you can hope for in case you don't posess documentation for some proprietary protocol (whether it's used there instead).

Related

What syntax does labview use when communicating

I'm using the same code that is still working for a new version of equipment the company the bought.
I can't communicate with the equipment in vb in visual studio (the language of the last code I wrote). But I can make a simple code in LabVIEW to see if the equipment is communicating and it is.
So, my question is what code is labview sending to the equipment?
The only thing I see from the LabVIEW GUI is *IDN?\n
Is that the same as what I writing?
mySerialport.WriteLine("*idn?" + Chr(10))
*IDN?\n
is not the same as :
mySerialport.WriteLine("*idn?" + Chr(10))
The former is capitalized while the later is not and it may cause an issue depending on the instrument.
You are using the serial port, so the most important thing to consider is the baud rate. It is possible that the later model equipment your company purchased has a different baud rate to the one that was used previously.
If you want to see exactly the data that LabVIEW is sending, you can use NI IO Trace or a non NI serial port monitor such as listed here
The question isn’t what language LabVIEW uses. LabVIEW is a programming environment with library APIs to speak to lots of hardware and the ability for anyone to write code to speak to even more hardware. The question is “what language does the HARDWARE speak?” To answer that, you’d post what kind of hardware it is and probably go to the manufacturer’s website for a spec sheet.
“*IDN?/n” looks like a GPIB command, which is just a framework serial protocol. You’d need the spec sheet of the hardware to know the particular commands that your hardware understands.
PS: LabVIEW doesn’t have a GUI showing anything about hardware communication. You have an application written in LabVIEW that has a GUI that is displaying information. You can edit the program to print out more info if you want, just like you could in VB. Complaining about the “LabVIEW GUI” in this case is equivalent to complaining about the Visual Studio GUI when the problem is with the program you’ve written in VS!
"The only thing I see from the labview GUI is *IDN?/n"
That sounds more like you are using the VISA Test Panel in MAX (Measurement and Automation eXplorer). It is related to LabVIEW in that it is also a tool developed by National Instruments (NI). But it does not sound like you have actually touched LabVIEW itself.
As was already stated, *IDN?\n is a typical command that an instrument that follows the SCPI messaging standard. On a Windows system, that is usually the same as "*idn?" + Chr(13) + Chr(10).
As SeanJ pointed out *IDN?\n is not the same as "idn?". Further, make sure that space character in your calling method is visible. Sometimes machines require you to manually type "\r\n" for complete carriage return.

USB MSC with STM32Cube

I'm using STM32Cube to generate simple USB MSC project. I'm using STM32F417VG.
So I'm selecting USB_OTG_FS - Device_only and USB_DEVICE - Class For FS IP - Mass Storage Class.
Then I'm generating source code, compile it and download to board, put it's USB cable to PC and nothing happens.
What am I doing wrong?
The STM32Cube application helps you get started on developing an application, but does not do the work for you. The generated code will include all the libraries necessary and initialize the hardware so that all the functions you selected are available and ready to go, and then begin an empty infinite loop. It will not show any outward behavior or respond to any external stimulus.
You will need to add some of your own code for the microcontroller to actually do anything.
If you are unsure what you need to do to make the USB functions work, take a look at the example projects that come with STM32Cube and the documentation comments in the library files it included in your project.
However, even a "simple" USB project can be relatively complex, and an unresponsive microcontroller can be mystifying. You may want to get your bearings with very simple GPIO-type projects. Making an LED blink is a microcontroller's "Hello World".

What is the nature of the gestures needed in Windows 8?

Most of touchpads on laptops don't handle multitouch, hence are not able to send swipe gestures to the OS.
Would it be possible to send some gestures to Windows from an external device, like a Teensy, or a recent Arduino, that can already emulate a keyboard and a mouse. I could send buttons 4 and 5 (mouse wheel up and down), but I would like to send a real swipe gesture (for example with a flex sensor...).
One of the ways that you could work with arduino and similar is to use the Microsoft .NET Microframework, which is an open source code, available for no cost from: Micro Framework
There are other frameworks available for the Artuino that you might want to use. So if you have a great idea on how to utilize the sensor hardware, then the output must meet certain specifications.
To be able to connect to your hardware that reads gestures, you will need to understand how drivers are created, so take a look at this: Info on drivers.
To find that type of information you would need to take a look at above link, this is for sensors, which would appear to be not quite what you are looking for, you are looking to use "gestures" but first you have to be able to make the connection to your device, this guide MIGHT help. I have reviewed it for other reasons.
There is a bunch of stuff to dig through, but first of all, imo, is to understand how to get your software to communicate with Windows 8. Let me know if you have any other questions. I am not the best person, you might want to refer to the community at the Micro Framework link shown above.
Good luck.
That's perfectly possible. What your effectively suggesting is that you want to create your own input peripheral like a trackpad and use that to send inputs. As long as windows recognizes this device as an input source it will work.

Spoofing a game controller

I'm trying to write something that will allow a user to use a keyboard/mouse combination on a games console. The approach I've thought of is to do the following:
Figure out how input maps to output in the console's controller. This is good old trial and error, basically connecting the controller via USB to a computer and figuring out how the controller responds to input using detailed USB logging.
Then, write a userland program that takes keyboard/mouse input and converts it to the controller's output.
So far so good. Now comes the complicated bit. I need to figure out a way to connect my computer to the console, while making the console think that what is actually being connected is a standard controller. For this, I will need a way to create a fake USB device, which communicates over a USB port to the console. This is the part that I have no idea whatsoever how to do.
I guess I'm looking for a USB spoofing library of some sort, but I'm not sure where to start looking for something like this. Python bindings for the library would be great, but I'm not fussy. Similarly, something that works on Mac or Linux would be perfect, but I could live with a Windows-only library in a pinch.
USB doesn't work this way. USB involves a directed hierarchy of devices, and trying to connect two host devices (your computer and a console) will only result in bad things happen (like destroying the USB controllers in both devices).
Probably the best thing to do would be to use some sort of embedded processor like an Arduino to sit between your keyboard/mouse and the console to do the conversion.

What do I need to have to be ready to write a Compact Framework application communicating with GPS?

Simply I am asked to write an application for a smart device (smart cell phone), which will get the GPS coordinates from the device itself.
I have no smart device at all. And I am kind of lost among questions like how can I check if the device have a gps by using the code, if it has how can I obtain them in a "standard" way, do I need to be using frameworks like GeoFrameWork?
So, may somebody list the must or most required things I need to have ready?
Geoframeworks GPS.NET is free these days and it's pretty comprehensive so there's no point reinventing the wheel. It's also friendly to beginners which helps. I strongly recommend downloading it and playing with some of the sample apps. It's a bit tricky if you don't have a physical device to play around with but it does have GPS emulation classes that you can use.
All you need is a copy of VS2008 Pro with the Smart Device SDK installed.