From d6457f039f2fb609eaf08db81eda9adb7deaf7d6 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 22 Sep 2008 20:26:45 +0000 Subject: [PATCH] added support for MIDI out in WinMM MIDI client git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1684 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 5 ++++ src/core/midi/midi_winmm.cpp | 54 ++++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18333cd01..fa94ea5f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-09-22 Tobias Doerffel + + * src/core/midi/midi_winmm.cpp: + added support for MIDI out in WinMM MIDI client + 2008-09-22 Paul Giblock * plugins/midi_import/portsmf/allegro.cpp: diff --git a/src/core/midi/midi_winmm.cpp b/src/core/midi/midi_winmm.cpp index 13f713964..830873bca 100644 --- a/src/core/midi/midi_winmm.cpp +++ b/src/core/midi/midi_winmm.cpp @@ -63,6 +63,33 @@ void midiWinMM::processOutEvent( const midiEvent & _me, const midiTime & _time, const midiPort * _port ) { + const DWORD short_msg = ( _me.m_type + _me.channel() ) + + ( ( _me.m_data.m_param[0] & 0xff ) << 8 ) + + ( ( _me.m_data.m_param[1] & 0xff ) << 16 ); + + QStringList out_devs; + for( subMap::iterator it = m_outputSubs.begin(); + it != m_outputSubs.end(); ++it ) + { + for( midiPortList::iterator jt = it.value().begin(); + jt != it.value().end(); ++jt ) + { + if( *jt == _port ) + { + out_devs += it.key(); + break; + } + } + } + + for( QMap::iterator it = m_outputDevices.begin(); + it != m_outputDevices.end(); ++it ) + { + if( out_devs.contains( *it ) ) + { + midiOutShortMsg( it.key(), short_msg ); + } + } } @@ -119,7 +146,7 @@ void midiWinMM::subscribeReadablePort( midiPort * _port, if( _subscribe && _port->inputEnabled() == FALSE ) { printf( "port %s can't be (un)subscribed!\n", - _port->name().toAscii().constData() ); + _port->displayName().toAscii().constData() ); return; } @@ -140,17 +167,14 @@ void midiWinMM::subscribeWriteablePort( midiPort * _port, if( _subscribe && _port->outputEnabled() == FALSE ) { printf( "port %s can't be (un)subscribed!\n", - _port->name().toAscii().constData() ); + _port->displayName().toAscii().constData() ); return; } - if( m_outputSubs.contains( _dest ) ) + m_outputSubs[_dest].removeAll( _port ); + if( _subscribe ) { - m_outputSubs[_dest].removeAll( _port ); - if( _subscribe ) - { - m_outputSubs[_dest].push_back( _port ); - } + m_outputSubs[_dest].push_back( _port ); } } @@ -296,6 +320,20 @@ void midiWinMM::openDevices( void ) midiInStart( hm ); } } + + m_outputDevices.clear(); + for( int i = 0; i < midiOutGetNumDevs(); ++i ) + { + MIDIOUTCAPS c; + midiOutGetDevCaps( i, &c, sizeof( c ) ); + HMIDIOUT hm = 0; + MMRESULT res = midiOutOpen( &hm, i, NULL, NULL, CALLBACK_NULL ); + if( res == MMSYSERR_NOERROR ) + { + m_outputDevices[hm] = qstrdup( c.szPname ); +// midiOutStart( hm ); + } + } }