Logo Search packages:      
Sourcecode: csound version File versions

Composition.cpp

/**
 * C S O U N D
 *
 * L I C E N S E
 *
 * This software is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#if defined(_MSC_VER) && !defined(__GNUC__)
#pragma warning (disable:4786)
#endif
#include "Composition.hpp"
#include "System.hpp"

namespace csound
{
  Composition::Composition() :
    tonesPerOctave(12.0),
    conformPitches(false),
    cppSound(&cppSound_)
  {
  }

  Composition::~Composition()
  {
  }

00039   void Composition::render()
  {
    generate();
    createCsoundScore(csoundScoreHeader);
    perform();
  }

00046   void Composition::createCsoundScore(std::string addToScore, double extendSeconds)
  {
    System::inform("addToScore.length(): %d\n", addToScore.length());
    if (addToScore.length() > 2) {
      cppSound->removeScore();
      cppSound->addScoreLine(addToScore);
    }
    cppSound->addScoreLine(score.getCsoundScore(tonesPerOctave, conformPitches));
    char buffer[0x100];
    std::sprintf(buffer, "\ns %9.3f", extendSeconds);
    cppSound->addScoreLine(buffer);
    std::sprintf(buffer, "\ne %9.3f", extendSeconds);
    cppSound->addScoreLine(buffer);
    cppSound->exportForPerformance();
  }

00062   void Composition::perform()
  {
    cppSound->perform();
  }

00067   void Composition::generate()
  {
  }

00071   void Composition::clear()
  {
    score.clear();
    cppSound->removeScore();
  }

00077   Score &Composition::getScore()
  {
    return score;
  }

00082   void Composition::setCppSound(CppSound *cppSound)
  {
    if(!cppSound)
      {
        this->cppSound = &cppSound_;
      }
    else
      {
        this->cppSound = cppSound;
      }
  }

00094   CppSound *Composition::getCppSound()
  {
    return cppSound;
  }

00099   void Composition::write(const char *text)
  {
    System::message(text);
  }

  void Composition::setTonesPerOctave(double tonesPerOctave)
  {
    this->tonesPerOctave = tonesPerOctave;
  }

  double Composition::getTonesPerOctave() const
  {
    return tonesPerOctave;
  }

  void Composition::setConformPitches(bool conformPitches)
  {
    this->conformPitches = conformPitches;
  }

  bool Composition::getConformPitches() const
  {
    return conformPitches;
  }

00124   void Composition::setCsoundOrchestra(std::string orchestra)
  {
    cppSound->setOrchestra(orchestra);
  }

00129   std::string Composition::getCsoundOrchestra() const
  {
    return cppSound->getOrchestra();
  }

00134   void Composition::setCsoundScoreHeader(std::string header)
  {
    csoundScoreHeader = header;
  }

00139   std::string Composition::getCsoundScoreHeader() const
  {
    return csoundScoreHeader;
  }

00144   void Composition::arrange(int oldInstrumentNumber, int newInstrumentNumber)
  {
    score.arrange(oldInstrumentNumber, newInstrumentNumber);
  }

00149   void Composition::arrange(int oldInstrumentNumber,
                            int newInstrumentNumber,
                            double gain)
  {
    score.arrange(oldInstrumentNumber, newInstrumentNumber, gain);
  }

00156   void Composition::arrange(int oldInstrumentNumber,
                            int newInstrumentNumber,
                            double gain,
                            double pan)
  {
    score.arrange(oldInstrumentNumber, newInstrumentNumber, gain, pan);
  }

00164   void Composition::arrange(int silenceInstrumentNumber, std::string csoundInstrumentName)
  {
    int csoundInstrumentNumber = cppSound->getInstrumentNumber(csoundInstrumentName);
    arrange(silenceInstrumentNumber, csoundInstrumentNumber);
  }

00170   void Composition::arrange(int silenceInstrumentNumber, std::string csoundInstrumentName, double gain)
  {
    int csoundInstrumentNumber = cppSound->getInstrumentNumber(csoundInstrumentName);
    arrange(silenceInstrumentNumber, csoundInstrumentNumber, gain);
   }

00176   void Composition::arrange(int silenceInstrumentNumber, std::string csoundInstrumentName, double gain, double pan)
  {
    int csoundInstrumentNumber = cppSound->getInstrumentNumber(csoundInstrumentName);
    arrange(silenceInstrumentNumber, csoundInstrumentNumber, gain, pan);
  }

00182   void Composition::removeArrangement()
  {
    score.removeArrangement();
  }

00187   void Composition::setCsoundCommand(std::string command)
  {
    cppSound->setCommand(command);
  }

00192   std::string Composition::getCsoundCommand() const
  {
    return cppSound->getCommand();
  }
}

Generated by  Doxygen 1.6.0   Back to index