/[svn]/qsampler/trunk/src/qsamplerMainForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.cpp

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

revision 1515 by capela, Fri Nov 23 18:15:33 2007 UTC revision 1558 by capela, Thu Dec 6 09:35:33 2007 UTC
# Line 77  static inline long lroundf ( float x ) Line 77  static inline long lroundf ( float x )
77  }  }
78  #endif  #endif
79    
80    
81    // All winsock apps needs this.
82    #if defined(WIN32)
83    static WSADATA _wsaData;
84    #endif
85    
86    
87    namespace QSampler {
88    
89  // Timer constant stuff.  // Timer constant stuff.
90  #define QSAMPLER_TIMER_MSECS    200  #define QSAMPLER_TIMER_MSECS    200
91    
# Line 87  static inline long lroundf ( float x ) Line 96  static inline long lroundf ( float x )
96  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.
97    
98    
 // All winsock apps needs this.  
 #if defined(WIN32)  
 static WSADATA _wsaData;  
 #endif  
   
   
99  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
100  // qsamplerCustomEvent -- specialty for callback comunication.  // CustomEvent -- specialty for callback comunication.
101    
102  #define QSAMPLER_CUSTOM_EVENT   QEvent::Type(QEvent::User + 0)  #define QSAMPLER_CUSTOM_EVENT   QEvent::Type(QEvent::User + 0)
103    
104  class qsamplerCustomEvent : public QEvent  class CustomEvent : public QEvent
105  {  {
106  public:  public:
107    
108          // Constructor.          // Constructor.
109          qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData)          CustomEvent(lscp_event_t event, const char *pchData, int cchData)
110                  : QEvent(QSAMPLER_CUSTOM_EVENT)                  : QEvent(QSAMPLER_CUSTOM_EVENT)
111          {          {
112                  m_event = event;                  m_event = event;
# Line 126  private: Line 129  private:
129  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
130  // qsamplerMainForm -- Main window form implementation.  // qsamplerMainForm -- Main window form implementation.
131    
 namespace QSampler {  
   
132  // Kind of singleton reference.  // Kind of singleton reference.
133  MainForm* MainForm::g_pMainForm = NULL;  MainForm* MainForm::g_pMainForm = NULL;
134    
# Line 366  MainForm::~MainForm() Line 367  MainForm::~MainForm()
367    
368    
369  // Make and set a proper setup options step.  // Make and set a proper setup options step.
370  void MainForm::setup ( qsamplerOptions *pOptions )  void MainForm::setup ( Options *pOptions )
371  {  {
372          // We got options?          // We got options?
373          m_pOptions = pOptions;          m_pOptions = pOptions;
# Line 382  void MainForm::setup ( qsamplerOptions * Line 383  void MainForm::setup ( qsamplerOptions *
383          if (m_pOptions->bKeepOnTop)          if (m_pOptions->bKeepOnTop)
384                  wflags |= Qt::Tool;                  wflags |= Qt::Tool;
385          // Some child forms are to be created right now.          // Some child forms are to be created right now.
386          m_pMessages = new qsamplerMessages(this);          m_pMessages = new Messages(this);
387          m_pDeviceForm = new DeviceForm(this, wflags);          m_pDeviceForm = new DeviceForm(this, wflags);
388  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
389          m_pInstrumentListForm = new InstrumentListForm(this, wflags);          m_pInstrumentListForm = new InstrumentListForm(this, wflags);
# Line 511  void MainForm::dropEvent ( QDropEvent* p Line 512  void MainForm::dropEvent ( QDropEvent* p
512                  QListIterator<QUrl> iter(pMimeData->urls());                  QListIterator<QUrl> iter(pMimeData->urls());
513                  while (iter.hasNext()) {                  while (iter.hasNext()) {
514                          const QString& sPath = iter.next().toLocalFile();                          const QString& sPath = iter.next().toLocalFile();
515                          if (qsamplerChannel::isInstrumentFile(sPath)) {                          if (Channel::isInstrumentFile(sPath)) {
516                                  // Try to create a new channel from instrument file...                                  // Try to create a new channel from instrument file...
517                                  qsamplerChannel *pChannel = new qsamplerChannel();                                  Channel *pChannel = new Channel();
518                                  if (pChannel == NULL)                                  if (pChannel == NULL)
519                                          return;                                          return;
520                                  // Start setting the instrument filename...                                  // Start setting the instrument filename...
# Line 549  void MainForm::customEvent(QEvent* pCust Line 550  void MainForm::customEvent(QEvent* pCust
550  {  {
551          // For the time being, just pump it to messages.          // For the time being, just pump it to messages.
552          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {          if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
553                  qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;                  CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent);
554                  if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) {                  if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) {
555                          int iChannelID = pEvent->data().toInt();                          int iChannelID = pEvent->data().toInt();
556                          ChannelStrip *pChannelStrip = channelStrip(iChannelID);                          ChannelStrip *pChannelStrip = channelStrip(iChannelID);
# Line 576  void MainForm::contextMenuEvent( QContex Line 577  void MainForm::contextMenuEvent( QContex
577  // qsamplerMainForm -- Brainless public property accessors.  // qsamplerMainForm -- Brainless public property accessors.
578    
579  // The global options settings property.  // The global options settings property.
580  qsamplerOptions *MainForm::options (void) const  Options *MainForm::options (void) const
581  {  {
582          return m_pOptions;          return m_pOptions;
583  }  }
# Line 737  bool MainForm::closeSession ( bool bForc Line 738  bool MainForm::closeSession ( bool bForc
738                  for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {                  for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
739                          ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel);                          ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel);
740                          if (pChannelStrip) {                          if (pChannelStrip) {
741                                  qsamplerChannel *pChannel = pChannelStrip->channel();                                  Channel *pChannel = pChannelStrip->channel();
742                                  if (bForce && pChannel)                                  if (bForce && pChannel)
743                                          pChannel->removeChannel();                                          pChannel->removeChannel();
744                                  delete pChannelStrip;                                  delete pChannelStrip;
# Line 877  bool MainForm::saveSessionFile ( const Q Line 878  bool MainForm::saveSessionFile ( const Q
878    
879          // Audio device mapping.          // Audio device mapping.
880          QMap<int, int> audioDeviceMap;          QMap<int, int> audioDeviceMap;
881          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);          piDeviceIDs = Device::getDevices(m_pClient, Device::Audio);
882          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
883                  ts << endl;                  ts << endl;
884                  qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]);                  Device device(Device::Audio, piDeviceIDs[iDevice]);
885                  // Audio device specification...                  // Audio device specification...
886                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
887                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
888                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
889                  qsamplerDeviceParamMap::ConstIterator deviceParam;                  DeviceParamMap::ConstIterator deviceParam;
890                  for (deviceParam = device.params().begin();                  for (deviceParam = device.params().begin();
891                                  deviceParam != device.params().end();                                  deviceParam != device.params().end();
892                                          ++deviceParam) {                                          ++deviceParam) {
893                          const qsamplerDeviceParam& param = deviceParam.value();                          const DeviceParam& param = deviceParam.value();
894                          if (param.value.isEmpty()) ts << "# ";                          if (param.value.isEmpty()) ts << "# ";
895                          ts << " " << deviceParam.key() << "='" << param.value << "'";                          ts << " " << deviceParam.key() << "='" << param.value << "'";
896                  }                  }
897                  ts << endl;                  ts << endl;
898                  // Audio channel parameters...                  // Audio channel parameters...
899                  int iPort = 0;                  int iPort = 0;
900                  QListIterator<qsamplerDevicePort *> iter(device.ports());                  QListIterator<DevicePort *> iter(device.ports());
901                  while (iter.hasNext()) {                  while (iter.hasNext()) {
902                          qsamplerDevicePort *pPort = iter.next();                          DevicePort *pPort = iter.next();
903                          qsamplerDeviceParamMap::ConstIterator portParam;                          DeviceParamMap::ConstIterator portParam;
904                          for (portParam = pPort->params().begin();                          for (portParam = pPort->params().begin();
905                                          portParam != pPort->params().end();                                          portParam != pPort->params().end();
906                                                  ++portParam) {                                                  ++portParam) {
907                                  const qsamplerDeviceParam& param = portParam.value();                                  const DeviceParam& param = portParam.value();
908                                  if (param.fix || param.value.isEmpty()) ts << "# ";                                  if (param.fix || param.value.isEmpty()) ts << "# ";
909                                  ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice                                  ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice
910                                          << " " << iPort << " " << portParam.key()                                          << " " << iPort << " " << portParam.key()
# Line 919  bool MainForm::saveSessionFile ( const Q Line 920  bool MainForm::saveSessionFile ( const Q
920    
921          // MIDI device mapping.          // MIDI device mapping.
922          QMap<int, int> midiDeviceMap;          QMap<int, int> midiDeviceMap;
923          piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);          piDeviceIDs = Device::getDevices(m_pClient, Device::Midi);
924          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {          for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
925                  ts << endl;                  ts << endl;
926                  qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]);                  Device device(Device::Midi, piDeviceIDs[iDevice]);
927                  // MIDI device specification...                  // MIDI device specification...
928                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
929                          << " " << tr("Device") << " " << iDevice << endl;                          << " " << tr("Device") << " " << iDevice << endl;
930                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
931                  qsamplerDeviceParamMap::ConstIterator deviceParam;                  DeviceParamMap::ConstIterator deviceParam;
932                  for (deviceParam = device.params().begin();                  for (deviceParam = device.params().begin();
933                                  deviceParam != device.params().end();                                  deviceParam != device.params().end();
934                                          ++deviceParam) {                                          ++deviceParam) {
935                          const qsamplerDeviceParam& param = deviceParam.value();                          const DeviceParam& param = deviceParam.value();
936                          if (param.value.isEmpty()) ts << "# ";                          if (param.value.isEmpty()) ts << "# ";
937                          ts << " " << deviceParam.key() << "='" << param.value << "'";                          ts << " " << deviceParam.key() << "='" << param.value << "'";
938                  }                  }
939                  ts << endl;                  ts << endl;
940                  // MIDI port parameters...                  // MIDI port parameters...
941                  int iPort = 0;                  int iPort = 0;
942                  QListIterator<qsamplerDevicePort *> iter(device.ports());                  QListIterator<DevicePort *> iter(device.ports());
943                  while (iter.hasNext()) {                  while (iter.hasNext()) {
944                          qsamplerDevicePort *pPort = iter.next();                          DevicePort *pPort = iter.next();
945                          qsamplerDeviceParamMap::ConstIterator portParam;                          DeviceParamMap::ConstIterator portParam;
946                          for (portParam = pPort->params().begin();                          for (portParam = pPort->params().begin();
947                                          portParam != pPort->params().end();                                          portParam != pPort->params().end();
948                                                  ++portParam) {                                                  ++portParam) {
949                                  const qsamplerDeviceParam& param = portParam.value();                                  const DeviceParam& param = portParam.value();
950                                  if (param.fix || param.value.isEmpty()) ts << "# ";                                  if (param.fix || param.value.isEmpty()) ts << "# ";
951                                  ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice                                  ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice
952                                  << " " << iPort << " " << portParam.key()                                  << " " << iPort << " " << portParam.key()
# Line 1037  bool MainForm::saveSessionFile ( const Q Line 1038  bool MainForm::saveSessionFile ( const Q
1038                  ChannelStrip* pChannelStrip                  ChannelStrip* pChannelStrip
1039                          = static_cast<ChannelStrip *> (wlist.at(iChannel));                          = static_cast<ChannelStrip *> (wlist.at(iChannel));
1040                  if (pChannelStrip) {                  if (pChannelStrip) {
1041                          qsamplerChannel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
1042                          if (pChannel) {                          if (pChannel) {
1043                                  ts << "# " << tr("Channel") << " " << iChannel << endl;                                  ts << "# " << tr("Channel") << " " << iChannel << endl;
1044                                  ts << "ADD CHANNEL" << endl;                                  ts << "ADD CHANNEL" << endl;
# Line 1069  bool MainForm::saveSessionFile ( const Q Line 1070  bool MainForm::saveSessionFile ( const Q
1070                                  ts << "LOAD INSTRUMENT NON_MODAL '"                                  ts << "LOAD INSTRUMENT NON_MODAL '"
1071                                          << pChannel->instrumentFile() << "' "                                          << pChannel->instrumentFile() << "' "
1072                                          << pChannel->instrumentNr() << " " << iChannel << endl;                                          << pChannel->instrumentNr() << " " << iChannel << endl;
1073                                  qsamplerChannelRoutingMap::ConstIterator audioRoute;                                  ChannelRoutingMap::ConstIterator audioRoute;
1074                                  for (audioRoute = pChannel->audioRouting().begin();                                  for (audioRoute = pChannel->audioRouting().begin();
1075                                                  audioRoute != pChannel->audioRouting().end();                                                  audioRoute != pChannel->audioRouting().end();
1076                                                          ++audioRoute) {                                                          ++audioRoute) {
# Line 1314  void MainForm::editAddChannel (void) Line 1315  void MainForm::editAddChannel (void)
1315                  return;                  return;
1316    
1317          // Just create the channel instance...          // Just create the channel instance...
1318          qsamplerChannel *pChannel = new qsamplerChannel();          Channel *pChannel = new Channel();
1319          if (pChannel == NULL)          if (pChannel == NULL)
1320                  return;                  return;
1321    
# Line 1352  void MainForm::editRemoveChannel (void) Line 1353  void MainForm::editRemoveChannel (void)
1353          if (pChannelStrip == NULL)          if (pChannelStrip == NULL)
1354                  return;                  return;
1355    
1356          qsamplerChannel *pChannel = pChannelStrip->channel();          Channel *pChannel = pChannelStrip->channel();
1357          if (pChannel == NULL)          if (pChannel == NULL)
1358                  return;                  return;
1359    
# Line 1924  void MainForm::updateSession (void) Line 1925  void MainForm::updateSession (void)
1925                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {                  for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1926                          // Check if theres already a channel strip for this one...                          // Check if theres already a channel strip for this one...
1927                          if (!channelStrip(piChannelIDs[iChannel]))                          if (!channelStrip(piChannelIDs[iChannel]))
1928                                  createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel]));                                  createChannelStrip(new Channel(piChannelIDs[iChannel]));
1929                  }                  }
1930                  m_pWorkspace->setUpdatesEnabled(true);                  m_pWorkspace->setUpdatesEnabled(true);
1931          }          }
# Line 2176  void MainForm::updateMessagesCapture (vo Line 2177  void MainForm::updateMessagesCapture (vo
2177  // qsamplerMainForm -- MDI channel strip management.  // qsamplerMainForm -- MDI channel strip management.
2178    
2179  // The channel strip creation executive.  // The channel strip creation executive.
2180  ChannelStrip* MainForm::createChannelStrip ( qsamplerChannel *pChannel )  ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel )
2181  {  {
2182          if (m_pClient == NULL || pChannel == NULL)          if (m_pClient == NULL || pChannel == NULL)
2183                  return NULL;                  return NULL;
# Line 2248  ChannelStrip* MainForm::channelStrip ( i Line 2249  ChannelStrip* MainForm::channelStrip ( i
2249                  ChannelStrip* pChannelStrip                  ChannelStrip* pChannelStrip
2250                          = static_cast<ChannelStrip*> (wlist.at(iChannel));                          = static_cast<ChannelStrip*> (wlist.at(iChannel));
2251                  if (pChannelStrip) {                  if (pChannelStrip) {
2252                          qsamplerChannel *pChannel = pChannelStrip->channel();                          Channel *pChannel = pChannelStrip->channel();
2253                          if (pChannel && pChannel->channelID() == iChannelID)                          if (pChannel && pChannel->channelID() == iChannelID)
2254                                  return pChannelStrip;                                  return pChannelStrip;
2255                  }                  }
# Line 2530  lscp_status_t qsampler_client_callback ( Line 2531  lscp_status_t qsampler_client_callback (
2531          // as this is run under some other thread context.          // as this is run under some other thread context.
2532          // A custom event must be posted here...          // A custom event must be posted here...
2533          QApplication::postEvent(pMainForm,          QApplication::postEvent(pMainForm,
2534                  new qsamplerCustomEvent(event, pchData, cchData));                  new CustomEvent(event, pchData, cchData));
2535    
2536          return LSCP_OK;          return LSCP_OK;
2537  }  }

Legend:
Removed from v.1515  
changed lines
  Added in v.1558

  ViewVC Help
Powered by ViewVC