@@ -114,32 +114,35 @@ bool isThisEventMaskingPreviousEvent(MidiFileEvent_t currentEvent, MidiFileEvent
114114 && MidiFileEvent_getTick (currentEvent) == MidiFileEvent_getTick (previousEvent));
115115}
116116
117+
118+
117119void displayCurrentNote (int channel, unsigned int note){
120+ static unsigned int notePerChannel[CHANNEL_COUNT] = {NOTE_STOP, NOTE_STOP};
121+ const char * textPerChannel[CHANNEL_COUNT] = {" LEFT haptic : " ," , RIGHT haptic : " };
118122 const char * noteBaseNameArray[12 ] = {" C" ," C#" ," D" ," D#" ," E" ," F" ," F#" ," G" ," G#" ," A" ," A#" ," B" };
119123
120- switch (channel){
121- case 0 :
122- cout << " RIGHT haptic : " ;
123- break ;
124- case 1 :
125- cout << " LEFT haptic : " ;
126- break ;
127- default :
124+ if (channel >= CHANNEL_COUNT)
128125 return ;
129- }
130126
127+ notePerChannel[channel] = note;
131128
132129
133- // Write empty string
134- if (note >= NOTE_STOP){
135- cout << " OFF" ;
136- }
137- else {
138- // Write note name
139- cout << noteBaseNameArray[note%12 ];
140- cout << (note/12 )-1 ;
130+ for (int i = 0 ; i < CHANNEL_COUNT ; i++){
131+ cout << textPerChannel[i];
132+
133+ // Write empty string
134+ if (notePerChannel[i] >= NOTE_STOP){
135+ cout << " OFF" ;
136+ }
137+ else {
138+ // Write note name
139+ cout << noteBaseNameArray[notePerChannel[i]%12 ];
140+ cout << (notePerChannel[i]/12 )-1 ;
141+ }
141142 }
142- cout << endl;
143+
144+ cout << " \r " ;
145+ cout.flush ();
143146}
144147
145148void playSong (libusb_device_handle *steamcontroller_handle, const char * songfile, unsigned int sleepIntervalUsec){
@@ -163,7 +166,6 @@ void playSong(libusb_device_handle *steamcontroller_handle, const char* songfile
163166 // Waiting for user to press enter
164167 cout << " Starting playback of " <<songfile << endl;
165168 sleep (1 );
166- cout << endl;
167169
168170 // Get current time point, will be used to know elapsed time
169171 std::chrono::steady_clock::time_point tOrigin = std::chrono::steady_clock::now ();
@@ -218,7 +220,7 @@ void playSong(libusb_device_handle *steamcontroller_handle, const char* songfile
218220
219221 }
220222
221- cout << " Playback completed " << endl;
223+ cout <<endl<< " Playback completed " << endl;
222224}
223225
224226
0 commit comments