midi_read_msg   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/external/midi.xtm

Implementation

(bind-func midi_read_msg
  (let ((buffer_length 1024)
        (input_buffer:PmEvent* (zalloc buffer_length))
        (msg:PmMessage 0)
        (timestamp:i32 0)
        (read_count 0)
        (i:i32 0))
    (lambda ()
      (set! read_count 0)
      ;; if you have more than one midi input device, you should call
      ;; Pm_Read on all your devices here
      (set! read_count (Pm_Read midi_in input_buffer buffer_length))
      (if (> read_count 0)
          (begin
            (dotimes (i read_count)
              (set! msg (tref (pref-ptr input_buffer i) 0))
              (set! timestamp (tref (pref-ptr input_buffer i) 1))
              (cond ((= (Pm_Message_Type msg) MIDI_NOTE_ON)
                     (enqueue_midi_event msg timestamp)
                     (if (= (Pm_Message_Data2 msg) 0)
                         (midi_note_off timestamp
                                        (Pm_Message_Data1 msg)
                                        (Pm_Message_Data2 msg)
                                        (Pm_Message_Channel msg))
                         (midi_note_on timestamp
                                       (Pm_Message_Data1 msg)
                                       (Pm_Message_Data2 msg)
                                       (Pm_Message_Channel msg))))
                    ((= (Pm_Message_Type msg) MIDI_NOTE_OFF)
                     (enqueue_midi_event msg timestamp)
                     (midi_note_off timestamp
                                    (Pm_Message_Data1 msg)
                                    (Pm_Message_Data2 msg)
                                    (Pm_Message_Channel msg)))
                    ((= (Pm_Message_Type msg) MIDI_CONTROL_CHANGE)
                     (if XTM_MIDI_CC_QUEUEING (enqueue_midi_event msg timestamp))
                     (midi_cc timestamp
                              (Pm_Message_Data1 msg)
                              (Pm_Message_Data2 msg)
                              (Pm_Message_Channel msg)))
                    (else
                     (midi_msg timestamp
                               (Pm_Message_Type msg)
                               (Pm_Message_Data1 msg)
                               (Pm_Message_Data2 msg)
                               (Pm_Message_Channel msg)
                               msg)))
              void)
            void)
          void))))


Back to Index

Similar Entries

  • *midioffset*    scheme
  • AudioBuffer_read    xtlang
  • AudioBuffer_read    xtlang
  • AudioBuffer_read_interp    xtlang
  • AudioBuffer_read_interp_mix    xtlang
  • AudioBuffer_read_interp_pw    xtlang
  • AudioBuffer_read_looped    xtlang
  • AudioBuffer_read_looped    xtlang
  • astra_readX    xtlang
  • astra_reader    xtlang
  • audiofile_aiff_read_samples    xtlang
  • audiofile_read_samples    xtlang
  • audiofile_wave_read_samples    xtlang
  • available_midi_events    xtlang
  • dequeue_midi_event    xtlang
  • enqueue_midi_event    xtlang
  • get-midi-device-names-alist    scheme
  • get-midi-input-device-names-alist    scheme
  • get-midi-output-device-names-alist    scheme
  • get_midi_evt_a    xtlang
  • get_midi_evt_b    xtlang
  • get_midi_evt_channel    xtlang
  • get_midi_evt_clocktime    xtlang
  • get_midi_evt_timestamp    xtlang
  • get_midi_evt_type    xtlang
  • get_midi_in    xtlang
  • get_midi_out    xtlang
  • gl_print_error_no_msg    xtlang
  • gl_print_error_with_msg    xtlang
  • homo-play-midi-note    scheme
  • homo-play-midi-note    scheme
  • impc:compiler:print-already-bound-error    scheme
  • midi-cc    scheme
  • midi-loop    scheme
  • midi-loop    scheme
  • midi-note-off    scheme
  • midi-note-on    scheme
  • midi2frq    scheme
  • midi_cc    xtlang
  • midi_cc    xtlang
  • midi_cc    xtlang
  • midi_cc    xtlang
  • midi_high_shelf    xtlang
  • midi_input_polling    xtlang
  • midi_input_port_id    xtlang
  • midi_low_shelf    xtlang
  • midi_lower_mid    xtlang
  • midi_msg    xtlang
  • midi_note_off    xtlang
  • midi_note_off    xtlang
  • midi_note_off    xtlang
  • midi_note_on    xtlang
  • midi_note_on    xtlang
  • midi_note_on    xtlang
  • midi_output_port_id    xtlang
  • midi_read_loop    xtlang
  • midi_upper_mid    xtlang
  • nonblocking_read_loop    xtlang
  • nonblocking_read_loop    xtlang
  • nonblocking_read_loop    xtlang
  • nonblocking_read_loop    xtlang
  • ocv_imread    xtlang
  • ocv_imread    xtlang
  • ocv_imread    scheme
  • ocv_imread1    xtlang
  • ocv_imread2    xtlang
  • ocv_read    xtlang
  • ocv_read    xtlang
  • ocv_read    scheme
  • ocv_read1    xtlang
  • ocv_read2    xtlang
  • play-midi-note    scheme
  • play-midi-note    scheme
  • print_midi_devices    xtlang
  • read_and_write_frame    xtlang
  • rtmidi_default_callback:RtMidiCCallback    xtlang
  • rtmidi_print_ports    xtlang
  • rtmidi_process_message    xtlang
  • rtmidi_register_callback    xtlang
  • rtmidi_send    xtlang
  • sampler-parse-midinote-filename    scheme
  • scheme-midi-listener    scheme
  • scientific-pitch-notation-to-midi-number    scheme
  • send-midi-cc    scheme
  • set_midi_in    xtlang
  • set_midi_out    xtlang
  • sf_read_file_into_buffer    xtlang
  • start_midi    xtlang
  • start_midi_scheduler    xtlang
  • svm_read_line    xtlang
  • svm_read_problem    xtlang
  • sys_file_read    xtlang
  • thread_native_call    xtlang
  • thread_native_call_with_zone    xtlang
  • xhid_read    xtlang