Juan MenendezB

Greenhorn
+ Follow
since Feb 25, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Juan MenendezB

OK, thanks a lot It's strange no one has mentioned this error before (have they?).
12 years ago
In the following code, which is copied as it is in page 390 of the book Head First Java, I came across a little issue I hope someone will help me clarify.

The expected output from running the program should be hearing the piano playing and at the same time in the console, everytime a note was played, the word "la" should we written. The purpose of this exercise was to explain how to handle ControlChange MIDI events (with code number 176) so we could do something at the same time any note was played (since we could not use the NoteOn event for the same purpose). The problem is that adding the event with command 176 on the same tick but right after the NoteOn event (command 144) (lines 18 and 19) seem to silence the note somehow. I tried to add it on tick i+1 and as expected I could hear more of the the note but silenced half way by the ControChange event.

I found the solution was to add the ControlChange midi event on the same tick but BEFORE the NoteOn event and not AFTER. Seems like the events are stored in a FIFO queue and this prevents the note from being silenced by the ControlChange event as it happened before.

The question is: am I doing the right thing changing the order of these two lines of code or should the program have worked in the order they were originally in the book?

12 years ago