java - What's the method to control volume in an MIDI sequencer? -
can show me how control volume of midi sequencer without using sound bank or synthesizer?
i want make midi fade out before continuing next midi in sequence
if(midiplay) { midi = s + savereq; try { //system.out.println("play midi " + midi); if (musicsr != null) { /* want fade out*/ musicsr.stop(); //stop sequencer musicsr.close(); //close sequencer } musicsr = null; musics = null; file music = new file(midi); if(music.exists()) { musics = midisystem.getsequence(music); } // create sequencer sequence musicsr = midisystem.getsequencer(); musicsr.open(); musicsr.setsequence(musics); musicsr.setloopcount(musicsr.loop_continuously); musicsr.start(); } catch (exception ex) { ex.printstacktrace(); } midiplay = false; }
- call getsequence sequence;
- call gettracks list of tracks;
in each track, each channel used in track, call add add multiple events @ appropriate time positions:
track.add(new midievent( new shortmessage(shortmessage.control_change, channel, 7, volume), tick));
- maybe remove other volume change events (that interfere fadeout) track;
- wait little time fadeout happen.
Comments
Post a Comment