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

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

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

revision 980 by capela, Sun Dec 17 22:29:29 2006 UTC revision 1499 by capela, Tue Nov 20 16:48:04 2007 UTC
# Line 1  Line 1 
1  // qsamplerInstrument.cpp  // qsamplerInstrument.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5       Copyright (C) 2007, Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 21  Line 22 
22    
23  #include "qsamplerAbout.h"  #include "qsamplerAbout.h"
24  #include "qsamplerInstrument.h"  #include "qsamplerInstrument.h"
25    #include "qsamplerUtilities.h"
26    
27  #include "qsamplerMainForm.h"  #include "qsamplerMainForm.h"
28    
29    
30    using namespace QSampler;
31    
32  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
33  // qsamplerInstrument - MIDI instrument map structure.  // qsamplerInstrument - MIDI instrument map structure.
34  //  //
# Line 157  bool qsamplerInstrument::mapInstrument ( Line 161  bool qsamplerInstrument::mapInstrument (
161  {  {
162  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
163    
164          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
165          if (pMainForm == NULL)          if (pMainForm == NULL)
166                  return false;                  return false;
167          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 190  bool qsamplerInstrument::mapInstrument ( Line 194  bool qsamplerInstrument::mapInstrument (
194          }          }
195    
196          if (::lscp_map_midi_instrument(pMainForm->client(), &instr,          if (::lscp_map_midi_instrument(pMainForm->client(), &instr,
197                  m_sEngineName.latin1(),                          m_sEngineName.toUtf8().constData(),
198                  m_sInstrumentFile.latin1(),                          qsamplerUtilities::lscpEscapePath(
199                  m_iInstrumentNr,                                  m_sInstrumentFile).toUtf8().constData(),
200                  m_fVolume,                          m_iInstrumentNr,
201                  load_mode,                          m_fVolume,
202                  m_sName.latin1()) != LSCP_OK) {                          load_mode,
203                            m_sName.toUtf8().constData()) != LSCP_OK) {
204                  pMainForm->appendMessagesClient("lscp_map_midi_instrument");                  pMainForm->appendMessagesClient("lscp_map_midi_instrument");
205                  return false;                  return false;
206          }          }
# Line 217  bool qsamplerInstrument::unmapInstrument Line 222  bool qsamplerInstrument::unmapInstrument
222          if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0)          if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0)
223                  return false;                  return false;
224    
225          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
226          if (pMainForm == NULL)          if (pMainForm == NULL)
227                  return false;                  return false;
228          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 251  bool qsamplerInstrument::getInstrument ( Line 256  bool qsamplerInstrument::getInstrument (
256          if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0)          if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0)
257                  return false;                  return false;
258    
259          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
260          if (pMainForm == NULL)          if (pMainForm == NULL)
261                  return false;                  return false;
262          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 270  bool qsamplerInstrument::getInstrument ( Line 275  bool qsamplerInstrument::getInstrument (
275                  return false;                  return false;
276          }          }
277    
278          m_sName           = pInstrInfo->name;          m_sName           = qsamplerUtilities::lscpEscapedTextToRaw(pInstrInfo->name);
279          m_sEngineName     = pInstrInfo->engine_name;          m_sEngineName     = pInstrInfo->engine_name;
280          m_sInstrumentName = pInstrInfo->instrument_name;          m_sInstrumentName = qsamplerUtilities::lscpEscapedTextToRaw(pInstrInfo->instrument_name);
281          m_sInstrumentFile = pInstrInfo->instrument_file;          m_sInstrumentFile = qsamplerUtilities::lscpEscapedPathToPosix(pInstrInfo->instrument_file);
282          m_iInstrumentNr   = pInstrInfo->instrument_nr;          m_iInstrumentNr   = pInstrInfo->instrument_nr;
283          m_fVolume         = pInstrInfo->volume;          m_fVolume         = pInstrInfo->volume;
284    
# Line 312  QStringList qsamplerInstrument::getMapNa Line 317  QStringList qsamplerInstrument::getMapNa
317  {  {
318          QStringList maps;          QStringList maps;
319    
320          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
321          if (pMainForm == NULL)          if (pMainForm == NULL)
322                  return maps;                  return maps;
323          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 320  QStringList qsamplerInstrument::getMapNa Line 325  QStringList qsamplerInstrument::getMapNa
325    
326  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
327          int *piMaps = ::lscp_list_midi_instrument_maps(pMainForm->client());          int *piMaps = ::lscp_list_midi_instrument_maps(pMainForm->client());
328          for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) {          if (piMaps == NULL) {
329                  const QString& sMapName = getMapName(piMaps[iMap]);                  if (::lscp_client_get_errno(pMainForm->client()))
330                  if (!sMapName.isEmpty())                          pMainForm->appendMessagesClient("lscp_list_midi_instruments");
331                          maps.append(sMapName);          } else {
332                    for (int iMap = 0; piMaps[iMap] >= 0; iMap++) {
333                            const QString& sMapName = getMapName(piMaps[iMap]);
334                            if (!sMapName.isEmpty())
335                                    maps.append(sMapName);
336                    }
337          }          }
338  #endif  #endif
339    
# Line 335  QString qsamplerInstrument::getMapName ( Line 345  QString qsamplerInstrument::getMapName (
345  {  {
346          QString sMapName;          QString sMapName;
347    
348          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
349          if (pMainForm == NULL)          if (pMainForm == NULL)
350                  return sMapName;                  return sMapName;
351          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 344  QString qsamplerInstrument::getMapName ( Line 354  QString qsamplerInstrument::getMapName (
354  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
355          const char *pszMapName          const char *pszMapName
356                  = ::lscp_get_midi_instrument_map_name(pMainForm->client(), iMidiMap);                  = ::lscp_get_midi_instrument_map_name(pMainForm->client(), iMidiMap);
357          if (pszMapName == NULL)          if (pszMapName == NULL) {
358                  pszMapName = " -";                  pszMapName = " -";
359          sMapName = QString("%1 - %2").arg(iMidiMap).arg(pszMapName);                  if (::lscp_client_get_errno(pMainForm->client()))
360                            pMainForm->appendMessagesClient("lscp_get_midi_instrument_name");
361            }
362            sMapName = QString("%1 - %2").arg(iMidiMap).arg(qsamplerUtilities::lscpEscapedTextToRaw(pszMapName));
363  #endif  #endif
364    
365          return sMapName;          return sMapName;

Legend:
Removed from v.980  
changed lines
  Added in v.1499

  ViewVC Help
Powered by ViewVC