MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / openPort

Method openPort

TheForceEngine/TFE_Audio/RtMidi.cpp:3762–3781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3760}
3761
3762void MidiInWeb::openPort( unsigned int portNumber, const std::string &portName )
3763{
3764 if( !checkWebMidiAvailability() )
3765 return;
3766 if (open_port_number >= 0)
3767 return;
3768
3769 MAIN_THREAD_EM_ASM( {
3770 // In Web MIDI API world, there is no step to open a port, but we have to register the input callback instead.
3771 var input = window._rtmidi_internals_get_port_by_number($0, true);
3772 input.onmidimessage = function(e) {
3773 // In RtMidi world, timestamps are delta time from previous message, while in Web MIDI world
3774 // timestamps are relative to window creation time (i.e. kind of absolute time with window "epoch" time).
3775 var rtmidiTimestamp = window._rtmidi_internals_latest_message_timestamp == 0.0 ? 0.0 : e.timeStamp - window._rtmidi_internals_latest_message_timestamp;
3776 window._rtmidi_internals_latest_message_timestamp = e.timeStamp;
3777 Module.ccall( 'rtmidi_onMidiMessageProc', 'void', ['number', 'array', 'number', 'number'], [$1, e.data, e.data.length, rtmidiTimestamp] );
3778 };
3779 }, portNumber, &inputData_ );
3780 open_port_number = portNumber;
3781}
3782
3783void MidiInWeb::openVirtualPort( const std::string &portName )
3784{

Callers 2

openPortMethod · 0.45
selectOutputMethod · 0.45

Calls 1

checkWebMidiAvailabilityFunction · 0.85

Tested by

no test coverage detected