Commit ea2f0495 authored by Pila's avatar Pila

Slightly better display (note names)

parent 56c603dc
......@@ -16,7 +16,6 @@
using namespace std;
double midiFrequency[128] = {8.1758, 8.66196, 9.17702, 9.72272, 10.3009, 10.9134, 11.5623, 12.2499, 12.9783, 13.75, 14.5676, 15.4339, 16.3516, 17.3239, 18.354, 19.4454, 20.6017, 21.8268, 23.1247, 24.4997, 25.9565, 27.5, 29.1352, 30.8677, 32.7032, 34.6478, 36.7081, 38.8909, 41.2034, 43.6535, 46.2493, 48.9994, 51.9131, 55, 58.2705, 61.7354, 65.4064, 69.2957, 73.4162, 77.7817, 82.4069, 87.3071, 92.4986, 97.9989, 103.826, 110, 116.541, 123.471, 130.813, 138.591, 146.832, 155.563, 164.814, 174.614, 184.997, 195.998, 207.652, 220, 233.082, 246.942, 261.626, 277.183, 293.665, 311.127, 329.628, 349.228, 369.994, 391.995, 415.305, 440, 466.164, 493.883, 523.251, 554.365, 587.33, 622.254, 659.255, 698.456, 739.989, 783.991, 830.609, 880, 932.328, 987.767, 1046.5, 1108.73, 1174.66, 1244.51, 1318.51, 1396.91, 1479.98, 1567.98, 1661.22, 1760, 1864.66, 1975.53, 2093, 2217.46, 2349.32, 2489.02, 2637.02, 2793.83, 2959.96, 3135.96, 3322.44, 3520, 3729.31, 3951.07, 4186.01, 4434.92, 4698.64, 4978.03, 5274.04, 5587.65, 5919.91, 6271.93, 6644.88, 7040, 7458.62, 7902.13, 8372.02, 8869.84, 9397.27, 9956.06, 10548.1, 11175.3, 11839.8, 12543.9};
libusb_device_handle* SteamController_OpenAndClaim(int *interface_num){
libusb_device_handle* dev_handle;
......@@ -52,6 +51,8 @@ libusb_device_handle* SteamController_OpenAndClaim(int *interface_num){
int SteamController_PlayNote(libusb_device_handle *dev_handle, int haptic, unsigned int note,double duration = DURATION_MAX){
double midiFrequency[128] = {8.1758, 8.66196, 9.17702, 9.72272, 10.3009, 10.9134, 11.5623, 12.2499, 12.9783, 13.75, 14.5676, 15.4339, 16.3516, 17.3239, 18.354, 19.4454, 20.6017, 21.8268, 23.1247, 24.4997, 25.9565, 27.5, 29.1352, 30.8677, 32.7032, 34.6478, 36.7081, 38.8909, 41.2034, 43.6535, 46.2493, 48.9994, 51.9131, 55, 58.2705, 61.7354, 65.4064, 69.2957, 73.4162, 77.7817, 82.4069, 87.3071, 92.4986, 97.9989, 103.826, 110, 116.541, 123.471, 130.813, 138.591, 146.832, 155.563, 164.814, 174.614, 184.997, 195.998, 207.652, 220, 233.082, 246.942, 261.626, 277.183, 293.665, 311.127, 329.628, 349.228, 369.994, 391.995, 415.305, 440, 466.164, 493.883, 523.251, 554.365, 587.33, 622.254, 659.255, 698.456, 739.989, 783.991, 830.609, 880, 932.328, 987.767, 1046.5, 1108.73, 1174.66, 1244.51, 1318.51, 1396.91, 1479.98, 1567.98, 1661.22, 1760, 1864.66, 1975.53, 2093, 2217.46, 2349.32, 2489.02, 2637.02, 2793.83, 2959.96, 3135.96, 3322.44, 3520, 3729.31, 3951.07, 4186.01, 4434.92, 4698.64, 4978.03, 5274.04, 5587.65, 5919.91, 6271.93, 6644.88, 7040, 7458.62, 7902.13, 8372.02, 8869.84, 9397.27, 9956.06, 10548.1, 11175.3, 11839.8, 12543.9};
unsigned char dataBlob[64] = {0x8f,
0x07,
0x00, //Trackpad select : 0x01 = left, 0x00 = right
......@@ -113,13 +114,32 @@ bool isThisEventMaskingPreviousEvent(MidiFileEvent_t currentEvent, MidiFileEvent
&& MidiFileEvent_getTick(currentEvent) == MidiFileEvent_getTick(previousEvent));
}
void displayPlayedNotes(int haptic, unsigned int note){
if(note == NOTE_STOP){
cout << ((haptic == 0) ? "RIGHT" : "LEFT ") << " haptic : OFF " <<endl;
void displayCurrentNote(int channel, unsigned int note){
const char* noteBaseNameArray[12] = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
switch(channel){
case 0:
cout << "RIGHT haptic : ";
break;
case 1:
cout << "LEFT haptic : ";
break;
default:
return;
}
//Write empty string
if(note >= NOTE_STOP){
cout << "OFF";
}
else{
cout << ((haptic == 0) ? "RIGHT" : "LEFT ") << " haptic : note " << note <<endl;
//Write note name
cout << noteBaseNameArray[note%12];
cout << (note/12)-1;
}
cout << endl;
}
void playSong(libusb_device_handle *steamcontroller_handle, const char* songfile, unsigned int sleepIntervalUsec){
......@@ -143,6 +163,7 @@ void playSong(libusb_device_handle *steamcontroller_handle, const char* songfile
//Waiting for user to press enter
cout << "Starting playback of " <<songfile << endl;
sleep(1);
cout << endl;
//Get current time point, will be used to know elapsed time
std::chrono::steady_clock::time_point tOrigin = std::chrono::steady_clock::now();
......@@ -192,9 +213,9 @@ void playSong(libusb_device_handle *steamcontroller_handle, const char* songfile
}
SteamController_PlayNote(steamcontroller_handle,currentChannel,eventNote);
displayPlayedNotes(currentChannel, eventNote);
displayCurrentNote(currentChannel, eventNote);
}
}
cout << "Playback completed " << endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment