zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

AudioOut.cpp (1145B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   AudioOut.h - Audio Output superclass
      5   Copyright (C) 2009-2010 Mark McCurry
      6   Author: Mark McCurry
      7 
      8   This program is free software; you can redistribute it and/or
      9   modify it under the terms of the GNU General Public License
     10   as published by the Free Software Foundation; either version 2
     11   of the License, or (at your option) any later version.
     12 */
     13 
     14 #include <iostream>
     15 #include <cstring>
     16 #include "SafeQueue.h"
     17 
     18 #include "OutMgr.h"
     19 #include "../Misc/Master.h"
     20 #include "AudioOut.h"
     21 
     22 using namespace std;
     23 
     24 namespace zyn {
     25 
     26 AudioOut::AudioOut(const SYNTH_T &synth_)
     27     :synth(synth_), samplerate(synth.samplerate), bufferSize(synth.buffersize)
     28 {}
     29 
     30 AudioOut::~AudioOut()
     31 {}
     32 
     33 void AudioOut::setSamplerate(int _samplerate)
     34 {
     35     samplerate = _samplerate;
     36 }
     37 
     38 int AudioOut::getSampleRate()
     39 {
     40     return samplerate;
     41 }
     42 
     43 void AudioOut::setBufferSize(int _bufferSize)
     44 {
     45     bufferSize = _bufferSize;
     46 #if HAVE_BG_SYNTH_THREAD
     47     OutMgr::getInstance().setBackgroundSynth(_bufferSize < synth.buffersize);
     48 #endif
     49 }
     50 
     51 Stereo<float *> AudioOut::getNext()
     52 {
     53     return OutMgr::getInstance().tick(bufferSize);
     54 }
     55 
     56 }