views:

23

answers:

0

Hi.

I am currently programming a Piano Keyboard editor, much like the one you can find in Cubase, Logic, Reason etc..

I have this big grid, double array new int [13][9], which makes it 13 rows, 9 columns. The first column [0-12][0] is the Keyboard, at the top there's "high C" (midi note 72) and at the bottom there's "low C" (midi note 60). That column is an array of JButtons and when you press for example "low C", note 60 is being played by the Synthesizer.

I've gotten this to work pretty OK as for now, but one problem I have is that I can only play 16 notes in a row, then it's like the Synthesizer shuts down or something.

Do you guys have ANY idea of what the problem is?

A bit of the code:

 import java.awt.*;
        import javax.swing.*;
        import java.awt.event.*;
        import java.util.*;
        import javax.sound.midi.*;

    actionPerformed(ActionEvent ae){
    for(int i = 0; i<13; i++){
            if(o== instr[i]){//instr is the button array
                SpelaTangent(i);
            }
        }

    }

    public void SpelaTangent(int tangent){


            int [] klaviatur = new int[13];
            for(int i = 0; i<13; i++){

                klaviatur[i] = (72-i);
                }

                         try {
                       Synthesizer synth = MidiSystem.getSynthesizer();                

synth.open(); 
                       final MidiChannel[] mc    = synth.getChannels();               

 Instrument[]        instrument = synth.getDefaultSoundbank().getInstruments();     

               synth.loadInstrument(instrument[1]);  
                        mc[0].noteOn(klaviatur[tangent],350);
                        mc[0].noteOff(klaviatur[tangent],350);

                   } catch (MidiUnavailableException e) {}
    }

Help is very much appreciated!