This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

using Midi player for interactive app - makes horrible clicking sound  RSS feed

Meg Smitley
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I am endeavouring to develop an interactive music-making application on the Nokia 6230 phone. The idea is that 2+ phones, connected via Bluetooth, may pass notes to one another, and thus create musical compositions.

My problem is that in order to play the notes, I have to stop the player and create a new player for each note. This results in a clicking sound as the palyer switches on and after, when deployed to the phones (this is note very apparent in the WTK22 emulator). If I do not stop and recreate a new player for each note, the application ceases to play notes' sound after a short period of operation.

I have made an exhaustive search of Internet resources � I think � for code samples/tutorials/ideas, and have come up short. Available information seems to relate to creating a song, loading it and playing it through � rather than interactively creating one on the fly � or playing a composition located at a URL.

Note, the interface is wheel shaped, with an arm that sweeps in a circle, playing each note that it encounters.

Please find below, the methods from the MIDlet: playCurrentNotes() and setupMidi(). As well as the run() method from an engine class which moves the arm and calls playCurrentNotes(). I would be grateful for any ideas.


public void playCurrentNotes() {
if(instruments != null) {
for(int i = 0; i < TOTAL_INSTRUMENTS; i++) {
if(instruments[i] != null) {
if(instruments[i].getNote(playPosition) != null) {
int value=
if(value > 0) {
try {
if (player != null){
(MIDIControl.NOTE_ON, playPosition, 50);
} catch (MediaException e) {
//method for debugging in phone
printString("Exception playCurrentNotes: " + e);

private void setupMidi() {
player = Manager.createPlayer(Manager.MIDI_DEVICE_LOCATOR);
} catch (MediaException e) {
printString("Exception setupMidi a: " + e);
catch (IOException e) {
printString("Exception setupMidi b: " + e);

public void run() {
while(!done) {
try {
} catch (InterruptedException e) {
daisy.printString("Exception (de1): " + e);
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!