Consider the following code:
You will be given an int[][] that represents a song in the following fashion:
Each int[] is a musical event, which can consist of one or more notes either playing or stopping.
Each int[][] is a series of numbers representing the actions in the event. The series begins with an int representing the time that the computer must wait before beginning the next event. After this, multiple actions may take place. Each action is placed into groups of 4 as follows: [1 to play, 0 to stop], [Channel], [Note], [Volume]
So, if the numbers were 250 1 0 60 120 1 1 64 100, it would play note 60 on channel 0 at volume 120 and note 64 on channel 1 at volume 100. It would then sleep for 250 milliseconds.
There may be any number of groups of 4 (+1) in a set. Thus, if there are 5 numbers, that would represent one note being played or stopped during an event. If there were 13 numbers, there would be 3 notes played or stopped (like a chord), etc. During a "stop" event, the Volume int is ignored.
Your goal is to, given a properly formatted array, create the method public void play (int[][] song). Here is some code with a song that you can copy/paste to
test out your code:
So far, I have:
The brackets in the brackets are able to have 5 or more values. If there are more than 5 values, the a chord should be played. However, this code only plays each note individually. How do I fix this?