~ubuntu-branches/ubuntu/quantal/muse/quantal

« back to all changes in this revision

Viewing changes to muse/synth.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2010-11-17 21:43:38 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101117214338-1hvfl7oo2dsqnvrb
Tags: 1.1-0ubuntu1
* New upstream release (LP: #668631)
* Switch to dpkg-source 3.0 (quilt) format
* Switch to dh7 short form
* debian/rules:
  - added --enable-dssi and --enable-osc to conf flags for dssi support
  - added -ljackserver to LDFLAGS to fix a FTBFS because of --as-needed
* debian/control:
  - added build build dependency on liblo-dev and dssi-dev for dssi support
  - bump Standards-version to 3.9.1. No changes required.
* debian/muse.desktop, debian/muse.xpm: dropped as desktop file and icon is
  now shipped upstream.
* fix-desktop-categories.patch: fix Categories tag in upstream desktop file
* 10_es_locale_fix.dpatch: refreshed and converted to quilt as
  fix_es_locale.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "audio.h"
34
34
#include "midiseq.h"
35
35
#include "midictrl.h"
 
36
//#include "stringparam.h"
36
37
 
37
38
std::vector<Synth*> synthis;  // array of available synthis
38
39
 
126
127
      }
127
128
 
128
129
//---------------------------------------------------------
129
 
//   createSynthI
 
130
//   createSynthInstance
130
131
//    create a synthesizer instance of class "label"
131
132
//---------------------------------------------------------
132
133
 
133
134
//static SynthI* createSynthI(const QString& sclass)
134
 
static SynthI* createSynthI(const QString& sclass, const QString& label)
 
135
static SynthI* createSynthInstance(const QString& sclass, const QString& label)
135
136
      {
136
137
      //Synth* s = findSynth(sclass);
137
138
      Synth* s = findSynth(sclass, label);
149
150
                  }
150
151
            }
151
152
      else
152
 
            printf("synthi class:%s label:%s not found\n", sclass.latin1(), label.latin1());
 
153
            printf("createSynthInstance: synthi class:%s label:%s not found\n", sclass.latin1(), label.latin1());
153
154
      return si;
154
155
      }
155
156
 
230
231
      _openFlags  = 1;
231
232
      _readEnable = false;
232
233
      _writeEnable = false;
 
234
      
 
235
      _curBankH = 0;
 
236
      _curBankL = 0;
 
237
      _curProgram  = 0;
 
238
 
233
239
      setVolume(1.0);
234
240
      setPan(0.0);
235
241
      }
283
289
      }
284
290
 
285
291
//---------------------------------------------------------
 
292
//   currentProg
 
293
//---------------------------------------------------------
 
294
 
 
295
void SynthI::currentProg(unsigned long *prog, unsigned long *bankL, unsigned long *bankH)
 
296
{
 
297
  if(prog)
 
298
    *prog  = _curProgram;
 
299
  if(bankL)
 
300
    *bankL = _curBankL;
 
301
  if(bankH)
 
302
    *bankH = _curBankH;
 
303
}
 
304
 
 
305
//---------------------------------------------------------
286
306
//   init
287
307
//---------------------------------------------------------
288
308
 
300
320
      return _mess->channels();
301
321
      }
302
322
 
 
323
int MessSynthIF::totalOutChannels() const
 
324
      {
 
325
      return _mess->channels();
 
326
      }
 
327
 
 
328
int MessSynthIF::totalInChannels() const
 
329
      {
 
330
      return 0;
 
331
      }
 
332
 
303
333
//SynthIF* MessSynth::createSIF() const
304
334
SynthIF* MessSynth::createSIF(SynthI* si)
305
335
      {
327
357
      setIName(instanceName);   // set instrument name
328
358
      _sif        = s->createSIF(this);
329
359
      
330
 
      AudioTrack::setChannels(_sif->channels());
331
 
 
 
360
      // p3.3.38
 
361
      //AudioTrack::setChannels(_sif->channels());
 
362
      AudioTrack::setTotalOutChannels(_sif->totalOutChannels());
 
363
      AudioTrack::setTotalInChannels(_sif->totalInChannels());
 
364
      
332
365
      //---------------------------------------------------
333
366
      //  read available controller from synti
334
367
      //---------------------------------------------------
379
412
            iel->clear();
380
413
            }
381
414
 
382
 
      int idx = 0;
 
415
      unsigned long idx = 0;
383
416
      for (std::vector<float>::iterator i = initParams.begin(); i != initParams.end(); ++i, ++idx)
384
417
            _sif->setParameter(idx, *i);
 
418
      
 
419
      // p3.3.40 Since we are done with the (sometimes huge) initial parameters list, clear it. 
 
420
      // TODO: Decide: Maybe keep them around for a 'reset to previously loaded values' (revert) command? ...
 
421
      initParams.clear();      
 
422
      
385
423
      return false;
386
424
      }
387
425
 
531
569
//SynthI* Song::createSynthI(const QString& sclass)
532
570
SynthI* Song::createSynthI(const QString& sclass, const QString& label)
533
571
      {
534
 
      // Added by Tim. p3.3.13
535
572
      //printf("Song::createSynthI calling ::createSynthI class:%s\n", sclass.latin1());
536
573
      
537
574
      //SynthI* si = ::createSynthI(sclass);
538
 
      SynthI* si = ::createSynthI(sclass, label);
 
575
      //SynthI* si = ::createSynthI(sclass, label);
 
576
      SynthI* si = createSynthInstance(sclass, label);
539
577
      if(!si)
540
578
        return 0;
541
 
      // Added by Tim. p3.3.13
542
579
      //printf("Song::createSynthI created SynthI. Before insertTrack1...\n");
543
580
      
544
581
      insertTrack1(si, -1);
545
 
      // Added by Tim. p3.3.13
546
582
      //printf("Song::createSynthI after insertTrack1. Before msgInsertTrack...\n");
547
583
      
548
584
      msgInsertTrack(si, -1, true);       // add to instance list
549
 
      // Added by Tim. p3.3.13
550
585
      //printf("Song::createSynthI after msgInsertTrack. Before insertTrack3...\n");
551
586
      
552
587
      insertTrack3(si, -1);
553
588
 
554
 
      // Added by Tim. p3.3.13
555
589
      //printf("Song::createSynthI after insertTrack3. Adding default routes...\n");
556
590
      
557
591
      OutputList* ol = song->outputs();
558
592
      // add default route to master (first audio output)
559
593
      if (!ol->empty()) {
560
594
            AudioOutput* ao = ol->front();
561
 
            audio->msgAddRoute(Route(si, -1), Route(ao, -1));
 
595
            // p3.3.38
 
596
            //audio->msgAddRoute(Route(si, -1), Route(ao, -1));
 
597
            //audio->msgAddRoute(Route((AudioTrack*)si, -1), Route(ao, -1));
 
598
            // Make sure the route channel and channels are valid.
 
599
            audio->msgAddRoute(Route((AudioTrack*)si, 0, ((AudioTrack*)si)->channels()), Route(ao, 0, ((AudioTrack*)si)->channels()));
 
600
            
562
601
            audio->msgUpdateSoloStates();
563
602
            }
 
603
      
 
604
      // Now that the track has been added to the lists in insertTrack2(),
 
605
      //  if it's a dssi synth, OSC can find the synth, and initialize (and show) its native gui.
 
606
      // No, initializing OSC without actually showing the gui doesn't work, at least for 
 
607
      //  dssi-vst plugins - without showing the gui they exit after ten seconds.
 
608
      //si->initGui();
 
609
      
564
610
      return si;
565
611
      }
566
612
 
596
642
                  xml.qrectTag(level, "geometry", QRect(x, y, w, h));
597
643
            }
598
644
 
 
645
      _stringParamMap.write(level, xml, "stringParam");
 
646
      
 
647
      xml.tag(level, "curProgram bankH=\"%ld\" bankL=\"%ld\" prog=\"%ld\"/", _curBankH, _curBankL, _curProgram);
 
648
      
599
649
      _sif->write(level, xml);
600
650
      xml.etag(level, "SynthI");
601
651
      }
628
678
      }
629
679
 
630
680
//---------------------------------------------------------
 
681
//   SynthI::readProgram
 
682
//---------------------------------------------------------
 
683
 
 
684
void SynthI::readProgram(Xml& xml, const QString& name)
 
685
{
 
686
  for (;;) 
 
687
  {
 
688
    Xml::Token token = xml.parse();
 
689
    const QString tag = xml.s1();
 
690
    switch (token) 
 
691
    {
 
692
          case Xml::Error:
 
693
          case Xml::End:
 
694
                return;
 
695
          case Xml::TagStart:
 
696
                xml.unknown(name);
 
697
                break;
 
698
          case Xml::Attribut:
 
699
                if(tag == "bankH") 
 
700
                  _curBankH = xml.s2().toUInt();
 
701
                else
 
702
                if(tag == "bankL") 
 
703
                  _curBankL = xml.s2().toUInt();
 
704
                else
 
705
                if(tag == "prog") 
 
706
                  _curProgram = xml.s2().toUInt();
 
707
                else
 
708
                  xml.unknown(name);
 
709
                break;
 
710
          case Xml::TagEnd:
 
711
                if(tag == name) 
 
712
                  return;
 
713
          default:
 
714
                break;
 
715
    }
 
716
  }
 
717
}
 
718
 
 
719
//---------------------------------------------------------
631
720
//   SynthI::read
632
721
//---------------------------------------------------------
633
722
 
637
726
      QString label;
638
727
      
639
728
      int port = -1;
640
 
      bool startGui = false;
 
729
      bool startgui = false;
641
730
      QRect r;
642
731
 
643
732
      for (;;) {
655
744
                        else if (tag == "port")
656
745
                              port  = xml.parseInt();
657
746
                        else if (tag == "guiVisible")
658
 
                              startGui = xml.parseInt();
 
747
                              startgui = xml.parseInt();
659
748
                        else if (tag == "midistate")
660
749
                              readMidiState(xml);
661
750
                        else if (tag == "param") {
662
751
                              float val = xml.parseFloat();
663
752
                              initParams.push_back(val);
664
753
                              }
 
754
                        else if (tag == "stringParam") 
 
755
                              _stringParamMap.read(xml, tag);
 
756
                        else if (tag == "curProgram") 
 
757
                              readProgram(xml, tag);
665
758
                        else if (tag == "geometry")
666
759
                              r = readGeometry(xml, tag);
667
760
                        else if (AudioTrack::readProperties(xml, tag))
678
771
                              song->insertTrack0(this, -1);
679
772
                              if (port != -1 && port < MIDI_PORTS)
680
773
                                    midiPorts[port].setMidiDevice(this);
681
 
                              showGui(startGui);
 
774
                              
 
775
                              // Now that the track has been added to the lists in insertTrack2(),
 
776
                              //  if it's a dssi synth, OSC can find the synth, and initialize (and show) its native gui.
 
777
                              // No, initializing OSC without actually showing the gui doesn't work, at least for 
 
778
                              //  dssi-vst plugins - without showing the gui they exit after ten seconds.
 
779
                              //initGui();
 
780
                              showGui(startgui);
682
781
                              setGeometry(r.x(), r.y(), r.width(), r.height());
683
782
                              
684
783
                              mapRackPluginsToControllers();
685
784
                              
 
785
                              // Now that the track has been added to the lists in insertTrack2(), if it's a dssi synth 
 
786
                              //  OSC can find the track and its plugins, and start their native guis if required...
 
787
                              showPendingPluginNativeGuis();
 
788
                              
686
789
                              return;
687
790
                              }
688
791
                  default: