set volume to half every other note
This commit is contained in:
parent
51baa068d2
commit
e9591a2388
12
square_1.php
12
square_1.php
@ -30,10 +30,18 @@ foreach ($c1_data as $i => $arr)
|
|||||||
|
|
||||||
if (strcmp($arr[1],"0") == 0) //play a note (square)
|
if (strcmp($arr[1],"0") == 0) //play a note (square)
|
||||||
{
|
{
|
||||||
|
// change volume every other note to half volume
|
||||||
|
$volume = 80;
|
||||||
|
$bin_data[] = 0; // delta
|
||||||
|
$bin_data[] = 176; // controller event, channel 0
|
||||||
|
$bin_data[] = 7; // change volume
|
||||||
|
$bin_data[] = $i % 2 === 0 ? $volume : ($volume / 2); // volume level
|
||||||
|
|
||||||
//note on event
|
//note on event
|
||||||
for ($j = count($b_arr)-1; $j >= 0; $j--) //tick delay
|
for ($j = count($b_arr)-1; $j >= 0; $j--) //tick delay
|
||||||
array_push($bin_data,bindec($b_arr[$j]));
|
array_push($bin_data,bindec($b_arr[$j]));
|
||||||
|
|
||||||
|
|
||||||
array_push($bin_data,144); //note on, channel 0
|
array_push($bin_data,144); //note on, channel 0
|
||||||
array_push($bin_data,$note_array['square'][$arr[2]][5]); //MIDI note index
|
array_push($bin_data,$note_array['square'][$arr[2]][5]); //MIDI note index
|
||||||
array_push($bin_data,100); //velocity
|
array_push($bin_data,100); //velocity
|
||||||
@ -62,6 +70,7 @@ foreach ($c1_data as $i => $arr)
|
|||||||
for ($j = count($b_arr)-1; $j >= 0; $j--) //tick delay
|
for ($j = count($b_arr)-1; $j >= 0; $j--) //tick delay
|
||||||
array_push($bin_data,bindec($b_arr[$j]));
|
array_push($bin_data,bindec($b_arr[$j]));
|
||||||
|
|
||||||
|
|
||||||
array_push($bin_data,128); //note off, channel 0
|
array_push($bin_data,128); //note off, channel 0
|
||||||
array_push($bin_data,$note_array['square'][$arr[2]][5]);
|
array_push($bin_data,$note_array['square'][$arr[2]][5]);
|
||||||
array_push($bin_data,100); //velocity of release
|
array_push($bin_data,100); //velocity of release
|
||||||
@ -101,8 +110,9 @@ fwrite($filehandle,pack("I",176),1); //controller event, channel 0
|
|||||||
fwrite($filehandle,pack("I",7),1); //change volume
|
fwrite($filehandle,pack("I",7),1); //change volume
|
||||||
fwrite($filehandle,pack("I",80),1); //volume level
|
fwrite($filehandle,pack("I",80),1); //volume level
|
||||||
|
|
||||||
foreach ($bin_data as $val)
|
foreach ($bin_data as $val) {
|
||||||
fwrite($filehandle, pack("I", $val), 1);
|
fwrite($filehandle, pack("I", $val), 1);
|
||||||
|
}
|
||||||
|
|
||||||
//End track
|
//End track
|
||||||
fwrite($filehandle,pack("I",0),1);
|
fwrite($filehandle,pack("I",0),1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user