// // Programmer: Craig Stuart Sapp // Creation Date: Sun Nov 23 16:23:32 PST 1997 // Last Modified: Mon Nov 24 13:46:59 PST 1997 // Filename: ...sig/src/control/MidiPort/doc/directOut.cc // Syntax: C++ // $Smake: g++ -O3 -o %b %f && strip %b // // Description: Plays the MIDI note 60 on the internal soundcard // (AudioTrix Pro) #include #include #include #include #include int main(void) { unsigned char buffer[1000] = {0}; // MIDI output buffer int numElements = 0; // count of elements in buffer int midi_fd; // file descriptor midi_fd = open("/dev/dmmidi0", O_RDWR); if (midi_fd == -1) { cerr << "Unable to open MIDI port." << endl; exit(1); } // place a NOTE ON into the buffer buffer[0] = 0x90; // note on-command, channel 1 buffer[1] = 60; // pitch: middle C buffer[2] = 0x7f; // velocity: loudest possible numElements = 3; // send out the contents of the buffer int flag = write(midi_fd, buffer, numElements); if (flag == -1) { cerr << "Error: could not write data to device." << endl; exit(1); } flag = close(midi_fd); if (flag == -1) { cerr << "Error: could not close MIDI port." << endl; exit(1); } return 0; }