File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Simple Midi Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple Midi Problem" Watch "Simple Midi Problem" New topic

Simple Midi Problem

P Katergiathis

Joined: Feb 17, 2007
Posts: 3
... from a Java newbie, fluent in other languages.

I am trying to create a simple program that will open a midi out port on my computer and send a note to it. My computer is running Windows and i run the following code in order to find out the available midi ports on my machine:

The code reveals the following information:

... so , all i want to do is select any of these ports and send a C to it for a given time duration.

Any help is welcome.

Best Regards
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Welcome to JavaRanch.

I think the you need to create several objects, first a Sequencer, then a Track, then a MidiEvent, and finally a MidiMessage with the appropriate data. It looks like you need to know the MIDI file format for this.

An example -which doesn't actually look all that complicated- can be found here.
P Katergiathis

Joined: Feb 17, 2007
Posts: 3
Thank you for replying.
I am aware of the technique that you described (and the related example), yet it is not what i want, because it sends a note to a "synthesizer", namely the default windows synth of my on-board card.

What i need is a way to send a midi message (a midi event, actually) to a pre-defined "receiver", in order to drive (via midi) an external synth.

Take this code for example:

... taken from the book mentioned in the comment and it's related web site.
It gets a list of installed midi outputs and (supposedly) will send a midi event, yet it does not seem to work in the sense that the author does not provide adequate info on how to construct such a midi event, or the way that a specific "receiver" is selected.

Any more thoughts?

[ February 18, 2007: Message edited by: Panos Katergiathis ]
Johny Doey

Joined: Feb 17, 2007
Posts: 7
I don't know nothing about this, but was wondering if this can hep you:
The Java Sound API specification provides low-level support for audio operations such as audio playback and capture (recording), mixing, MIDI sequencing, and MIDI synthesis in an extensible, flexible framework.

taken from:
Does that sound like it's ossible to do what you want? Either way I found this FAQ:
I agree. Here's the link:
subject: Simple Midi Problem
It's not a secret anymore!