1

Say I have a player who is currently playing a pattern and at a certain point I want to set the next pattern that it should play without producing a small pause when it switches between the two.

It is similar to Android's mediaplayer class where you can have 2 mediaplayer which each is setNext to the other. With the use of setOnCompletion you can alternate between the two without hearing a small pause or gap. I want to achieve that in jFugue.

Thanks!

Ziad Halabi
  • 964
  • 11
  • 31

1 Answers1

1

You will want to use JFugue 5 for this, as it has improvements over earlier versions of JFugue for playing consecutive patterns. Specifically, you'll want to use the new RealtimePlayer. You can send the RealtimePlayer new patterns or music strings whenever you wish, like this:

 RealtimePlayer rt = new RealtimePlayer();
 rt.play(pattern1);
 rt.play(pattern2);
 rt.play("a music string works, too");
David Koelle
  • 20,726
  • 23
  • 93
  • 130
  • Thank you so much for your answer and for developing jFugue! I tried the code that you suggested, when I ran my program it didnt play anything. No exception was thrown too. What seems to be the problem? On the other hand, I have two other questions regarding jfugue: 1- Is it possible to input different soundfonts for different instruments? i.e. I have a player that is playing multiple instruments, I want to input a different soundfont for each instrument. 2- I want to implement my project as an Android App, I am trying to setup kshoji's jFugue for Android. Have you ever tested that project? – Ziad Halabi Feb 13 '15 at 15:07
  • You're welcome * 2. 0) Hard to diagnose the problem from a distance. Does it work with a regular Player object? 1) Yes, see also http://stackoverflow.com/questions/15996711/newer-version-of-jre-doesnt-load-soundbank-but-older-version-does 2) I plan to in the near future, but have not yet. Feel free to email me offline with follow-ups. – David Koelle Feb 13 '15 at 16:34
  • `RealtimePlayer rt = null; try { rt = new RealtimePlayer(); } catch (MidiUnavailableException e) { e.printStackTrace(); } Pattern pat = new Pattern("D5h E5h"); Player p = new Player(); p.play(pat); rt.play(pat); p.play("");` If I comment the last p.play(""), I only hear pat. If I leave it, I hear the pat and 1 millisecond of a chord. – Ziad Halabi Feb 15 '15 at 12:57
  • Please contact me directly for follow-up discussions. My email address is in my profile. – David Koelle Feb 17 '15 at 04:42