How to fetch MIDI input-data in C++? - c++

I've already googled the **** out of the web in search of a simple way to get data from a connected midi device. I'm using I Visual Studio 2010 on a Win7 64bit PC.
I've already tried libaries like Improv, JDKSmidi, Portmidi
All their example programs compiled with errors and Portmidi did not really provide a useful documentation.
All I want to do, is to read midi input on windows in my program. (Maybe even without an extern libary?)

Take a look at rtmidi. It is small (2 headers and one .cpp file) and very easy to use.
http://www.music.mcgill.ca/~gary/rtmidi/

If you are on windows, you may use Windows multimedia API.
It's quite simple.
MSDN MIDI Reference
There are several articles on codeproject :
http://www.codeproject.com/Articles/2771/Wrapper-Library-for-Windows-MIDI-API
http://www.codeproject.com/Articles/36313/MIDI-Star

Related

Converting a Linux Library Project into a Library Project usable in windows

I am attempting to convert the ndn library project found at "https://github.com/named-data/ndn-cpp" into something that can be imported into several existing mfc/wpf/forms Visual Studio Projects (building it as .lib or .dll would work).
As a note, it appears to have previously been converted into c# for windows for a older build of ndn, but is no long supported and will not connect with the current ndn network.(https://github.com/named-data/ndn-dot-net)
I have looked into the using the WSL features that they have added to windows 10, and the Visual studio Linux Cross Platform projects, but these all seem to only be able to make .exes that will run in windows not a .lib or .dll that can be imported into another project.
I have also look into the shared items project but what I was able to find didn't seem like it would work for what I'm trying to do.
Lastly, I tried using cygwin. I was able to compile and generate the linux style libraries(.a) on my windows 10 machine, but when i attempted to generate windows style dlls off the .o files(gcc -shared -o mydll.dll mydll.o) I ran into a large number of reference errors that I was unable to resolve.
Does anyone have any recommendations on which of these methods I should be using or if I should be attempting some other method entirely?
Does anyone have any good references or examples of how to do this for someone with limited Linux experience?
Thanks
Ok. I've tried going about this several ways now, and here's what I've learned that might be useful to someone else trying to do this and also where I stand so far:
If you have a simple Linux dll that you have written it's possible to compile it as a Windows dll using MSYS2 or MINGW, instructions are here: http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs
If you have something a bit more complicated like the program I'm trying to convert above, there is no quick fix to convert from Linux to windows, however you still might be able to compile your program for windows using Visual Studio.
Here's how you do it:
Download vcpkg from https://github.com/microsoft/vcpkg This is a linux package manager for windows, it will allow you to download windows equivalents to many common Linux packages (for the above I had to download boost and sqlite3)
Create your own unistd.h, here's a link to that: Is there a replacement for unistd.h for Windows (Visual C)?
Get dirent.h for windows, here's a link to that: https://github.com/tronkko/dirent
replace instances of gmtime with _mkgmtime or redefine gmtime as _mkgmtime: timegm cross platform
This got me about 90% of the way there (and from about 13,000 compiler errors to about 30), The rest of the errors so far have been for calls where there is no easy linux to windows conversion and those sections of code have had to be re-written. (In the code above this would be the socket code for the tcp/udp connections in the tranport files, Linux and Windows handle it pretty differently, boost does have a good guide for how to use it's sockets in windows though: https://www.boost.org/doc/libs/1_60_0/more/getting_started/windows.html)
So that's it. Hopefully this helps someone else down the line. I'll be adding more to this answer as I discover new things.

Function variants between different platforms when working with audio files

I was following a programming example for writing a small application the details of the application itself are not important. The issue or concern here is that within that application the provider is using the POSIX function popen().
The line of code looks like this:
static FILE* fp = popen( "resample mr1789800 r48000 | aplay -fdat 2>/dev/null", "w" );
And they were compiling their code with g++, I don't know what version they were using.
I am working on a Windows 7 x64 platform in Visual Studio 2017 with compiler set to latest drafted standard, all other options are default or standard settings. This is the general scenario.
All of the other code in the providers example is seems to be portable, this is the only piece of code that I've seen that is native to POSIX functionality.
It appears that they are using popen to load a file to an external program and by the looks from the code above it appears that the program is unix based aplay.
If I'm trying to mimic this behavior on Windows using Visual Studio what would be the required tools to use?
Will _popen() do the same thing, meaning are they nearly equivalent? If so, then the second half of the question is if aplay is the program that is opening the audio file, what options are available to me that are for windows that will handle the audio file the same way as the one that is found in a typical Unix type system? If not; what are the differences between the two and where would I go from here?

C++ Qt executable compatible with all windows computers?

I have had problems in the past using visual C++, when I ran the executable on other computers it required a .NET framework. I have now started looking at c++ Qt GUI builder and from what I have read C++ doesnt require any additional downloads apart from the executable file to be able to run on other computers, is this true? If I use Qt to build my GUI and send it to other users they will need no other external downloads?
I have now started looking at c++ Qt GUI builder and from what I have read C++ doesnt require any additional downloads apart from the executable file to be able to run on other computers, is this true?
Not necessarily; see below.
If I use Qt to build my GUI and send it to other users they will need no other external downloads?
You will potentially need to get redistributables installed on each user machine where this is needed, but this is not a Qt issue, just a generic principle how VS/MSVC and Windows work. However, there is no gentle way around to it in my understanding.
I'm not 100% sure, but I can tell you that some of my users need to download the Visual C++ Redistributable package. They would sometimes get a missing "msvcr.dll" error. Very frustrating. I tried including the file with the install, but it was picked up as a virus by some antivirus programs.

Build libpcap for Python 2.7.x in windows 7

I've tried several different things and crawled around on lots of forums looking for an answer to this question.
My goal is to simply parse through a wireshark .pcap-ng trace file using Python. From what I can gather, it seems like I need a libpcap wrapper for Python or perhaps WinCap (PyCapy?)
I'm relatively new to Python, so if you all have any pointers on how to install this module please let me know. Earlier I had a 32bit version of Python installed and found a win32 installer and was able to parse through .pcap files but I really want to be able to parse through the .pcapng files. Thanks guys,
~Kyte
Sadly, this is Windows, so WinPcap won't help; libpcap 1.1.0 and later can read pcap-ng files, but there is currently no version of WinPcap based on a version of libpcap with pcap-ng support.
I.e., currently, the first piece of software to try would be VirtualBox, Parallels Workstation, or VMware Workstation, and the next piece of software to try would be some Linux distribution running on your Windows machine under the virtualization software. Sorry.
(Yes, I have to find the time to do some libpcap infrastructure work to make it easier for the WinPcap people to make their remote capture support work with newer versions of libpcap. Sadly, there are only 24 hours in a day, and a ton of other things to do competing for the hours that remain after such frivolities as eating and sleeping. :-))
A workaround for that particular issue would be either to save a capture from Wireshark in pcap format rather than pcap-ng format or to use Wireshark tools such as editcap (which can handle pcap-ng files on Windows, as they don't use libpcap/WinPcap to read capture files) to convert from pcap-ng to pcap.
There are a couple of Python wrappers for libpcap/WinPcap - python-libpcap and Pcapy. The python-libpcap page has a daemon and a penguin on it, so they're only advertising BSD and Linux support; it might work on other UN*Xes, as there shouldn't be major differences in the way you hook into libpcap, but might not work on Windows. Pcapy, however, explicitly mentions WinPcap and Win32 binaries.
Do try out the pcap binary that #dirkloss compiled for Python 2.7 | Windows.
Here
I tried it , but I'm getting this error- SO qn

VSTSDK and Visual Studio Express 2010

I am new to C++ and Visual Studio and have two questions:
Where do I need to put the VSTSDK so that VS recognizes it and I can use it in my projects?
Does anybody have some sample code for a VST host?
It doesn't matter where you put the VST SDK, as long as you tell Visual Studio. In Visual Studio, you can add any library and #include path, and that's what you'll need from the SDK.
I would also recommend checking out the Audacity Source Code for a VST hosting example. There used to be a great vsthost.cpp example on the web, too, but I can't seem to find it. =/
There are some few examples like, vsthost, vstboard, audacity.
vsthost is using asio only, the 2 others are using portaudio and portmidi.
vstboard is using Qt for gui, audacity uses wxwidget.
The problem is : what kind of host do you need (simple for one plug in ora complex one) Also, you should take a look at JUCE library which offers good features for all of that even if I would prefer the vstboard design (Qt + portaudio)
good luck