/[svn]/linuxsampler/trunk/src/engines/gig/EngineChannel.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/EngineChannel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1659 by schoenebeck, Sun Feb 3 00:13:27 2008 UTC revision 1723 by schoenebeck, Sun Apr 20 08:53:39 2008 UTC
# Line 29  namespace LinuxSampler { namespace gig { Line 29  namespace LinuxSampler { namespace gig {
29    
30      EngineChannel::EngineChannel() :      EngineChannel::EngineChannel() :
31          InstrumentChangeCommandReader(InstrumentChangeCommand),          InstrumentChangeCommandReader(InstrumentChangeCommand),
32          virtualMidiDevicesReader(virtualMidiDevices)          virtualMidiDevicesReader_AudioThread(virtualMidiDevices),
33            virtualMidiDevicesReader_MidiThread(virtualMidiDevices)
34      {      {
35          pMIDIKeyInfo = new midi_key_info_t[128];          pMIDIKeyInfo = new midi_key_info_t[128];
36          pEngine      = NULL;          pEngine      = NULL;
# Line 510  namespace LinuxSampler { namespace gig { Line 511  namespace LinuxSampler { namespace gig {
511              event.pEngineChannel      = this;              event.pEngineChannel      = this;
512              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
513              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
514              // inform instrument editor(s), if any ...              // inform connected virtual MIDI devices if any ...
515              pEngine->instruments.TrySendNoteOnToEditors(Key, Velocity, pInstrument);              // (e.g. virtual MIDI keyboard in instrument editor(s))
516                ArrayList<VirtualMidiDevice*>& devices =
517                    const_cast<ArrayList<VirtualMidiDevice*>&>(
518                        virtualMidiDevicesReader_MidiThread.Lock()
519                    );
520                for (int i = 0; i < devices.size(); i++) {
521                    devices[i]->SendNoteOnToDevice(Key, Velocity);
522                }
523                virtualMidiDevicesReader_MidiThread.Unlock();
524          }          }
525      }      }
526    
# Line 538  namespace LinuxSampler { namespace gig { Line 547  namespace LinuxSampler { namespace gig {
547              event.pEngineChannel      = this;              event.pEngineChannel      = this;
548              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
549              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
550              // inform instrument editor(s), if any ...              // inform connected virtual MIDI devices if any ...
551              pEngine->instruments.TrySendNoteOnToEditors(Key, Velocity, pInstrument);              // (e.g. virtual MIDI keyboard in instrument editor(s))
552                ArrayList<VirtualMidiDevice*>& devices =
553                    const_cast<ArrayList<VirtualMidiDevice*>&>(
554                        virtualMidiDevicesReader_MidiThread.Lock()
555                    );
556                for (int i = 0; i < devices.size(); i++) {
557                    devices[i]->SendNoteOnToDevice(Key, Velocity);
558                }
559                virtualMidiDevicesReader_MidiThread.Unlock();
560          }          }
561      }      }
562    
# Line 561  namespace LinuxSampler { namespace gig { Line 578  namespace LinuxSampler { namespace gig {
578              event.pEngineChannel      = this;              event.pEngineChannel      = this;
579              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
580              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
581              // inform instrument editor(s), if any ...              // inform connected virtual MIDI devices if any ...
582              pEngine->instruments.TrySendNoteOffToEditors(Key, Velocity, pInstrument);              // (e.g. virtual MIDI keyboard in instrument editor(s))
583                ArrayList<VirtualMidiDevice*>& devices =
584                    const_cast<ArrayList<VirtualMidiDevice*>&>(
585                        virtualMidiDevicesReader_MidiThread.Lock()
586                    );
587                for (int i = 0; i < devices.size(); i++) {
588                    devices[i]->SendNoteOffToDevice(Key, Velocity);
589                }
590                virtualMidiDevicesReader_MidiThread.Unlock();
591          }          }
592      }      }
593    
# Line 589  namespace LinuxSampler { namespace gig { Line 614  namespace LinuxSampler { namespace gig {
614              event.pEngineChannel      = this;              event.pEngineChannel      = this;
615              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
616              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
617              // inform instrument editor(s), if any ...              // inform connected virtual MIDI devices if any ...
618              pEngine->instruments.TrySendNoteOffToEditors(Key, Velocity, pInstrument);              // (e.g. virtual MIDI keyboard in instrument editor(s))
619                ArrayList<VirtualMidiDevice*>& devices =
620                    const_cast<ArrayList<VirtualMidiDevice*>&>(
621                        virtualMidiDevicesReader_MidiThread.Lock()
622                    );
623                for (int i = 0; i < devices.size(); i++) {
624                    devices[i]->SendNoteOffToDevice(Key, Velocity);
625                }
626                virtualMidiDevicesReader_MidiThread.Unlock();
627          }          }
628      }      }
629    
# Line 704  namespace LinuxSampler { namespace gig { Line 737  namespace LinuxSampler { namespace gig {
737          MidiVolume     = 1.0;          MidiVolume     = 1.0;
738          GlobalPanLeft  = 1.0f;          GlobalPanLeft  = 1.0f;
739          GlobalPanRight = 1.0f;          GlobalPanRight = 1.0f;
740            iLastPanRequest = 64;
741          GlobalTranspose = 0;          GlobalTranspose = 0;
742          // set all MIDI controller values to zero          // set all MIDI controller values to zero
743          memset(ControllerTable, 0x00, 129);          memset(ControllerTable, 0x00, 129);
# Line 739  namespace LinuxSampler { namespace gig { Line 773  namespace LinuxSampler { namespace gig {
773              // as we're going to (carefully) write some status to the              // as we're going to (carefully) write some status to the
774              // synchronized struct, we cast away the const              // synchronized struct, we cast away the const
775              ArrayList<VirtualMidiDevice*>& devices =              ArrayList<VirtualMidiDevice*>& devices =
776                  const_cast<ArrayList<VirtualMidiDevice*>&>(virtualMidiDevicesReader.Lock());                  const_cast<ArrayList<VirtualMidiDevice*>&>(virtualMidiDevicesReader_AudioThread.Lock());
777              // iterate through all virtual MIDI devices              // iterate through all virtual MIDI devices
778              for (int i = 0; i < devices.size(); i++) {              for (int i = 0; i < devices.size(); i++) {
779                  VirtualMidiDevice* pDev = devices[i];                  VirtualMidiDevice* pDev = devices[i];
# Line 761  namespace LinuxSampler { namespace gig { Line 795  namespace LinuxSampler { namespace gig {
795              }              }
796          }          }
797          exitVirtualDevicesLoop:          exitVirtualDevicesLoop:
798          virtualMidiDevicesReader.Unlock();          virtualMidiDevicesReader_AudioThread.Unlock();
799    
800          // import events from the regular MIDI devices          // import events from the regular MIDI devices
801          RingBuffer<Event,false>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader();          RingBuffer<Event,false>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader();
# Line 842  namespace LinuxSampler { namespace gig { Line 876  namespace LinuxSampler { namespace gig {
876          bStatusChanged = true; // status of engine channel has changed, so set notify flag          bStatusChanged = true; // status of engine channel has changed, so set notify flag
877      }      }
878    
879        float EngineChannel::Pan() {
880            return float(iLastPanRequest - 64) / 64.0f;
881        }
882    
883        void EngineChannel::Pan(float f) {
884            int iMidiPan = int(f * 64.0f) + 64;
885            if (iMidiPan > 127) iMidiPan = 127;
886            else if (iMidiPan < 0) iMidiPan = 0;
887            GlobalPanLeft  = Engine::PanCurve[128 - iMidiPan];
888            GlobalPanRight = Engine::PanCurve[iMidiPan];
889            iLastPanRequest = iMidiPan;
890        }
891    
892      uint EngineChannel::Channels() {      uint EngineChannel::Channels() {
893          return 2;          return 2;
894      }      }

Legend:
Removed from v.1659  
changed lines
  Added in v.1723

  ViewVC Help
Powered by ViewVC