I want to implement a metronome app in Java for playing beats in complicated rhythm patterns. There are many kinds of beats, (drums and other percussion instruments) that's why using timers and threads may cause a not precise and optimal performance. I decided firstly to generate the sound by adding silence intervals for each instrument and then to mix them together for better performance (not sure if this is the best solution, but anyway). Now my problem is to add silence intervals to each beat.
public AudioStream create(String file, String rhythm) {
InputStream in = null;
AudioStream audioStream = null;
try {
in = new FileInputStream(path + file);
audioStream = new AudioStream(in);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
This function should create and return the sample for one instrument. So how can I add silence milliseconds to the file and then return the final sample?
Aucun commentaire:
Enregistrer un commentaire