zynaddsubfx

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

WavEngine.h (1225B)


      1 /*
      2   ZynAddSubFX - a software synthesizer
      3 
      4   WavEngine.h - Records sound to a file
      5   Copyright (C) 2008 Nasca Octavian Paul
      6   Author: Nasca Octavian Paul
      7           Mark McCurry
      8 
      9   This program is free software; you can redistribute it and/or
     10   modify it under the terms of the GNU General Public License
     11   as published by the Free Software Foundation; either version 2
     12   of the License, or (at your option) any later version.
     13 */
     14 
     15 #ifndef WAVENGINE_H
     16 #define WAVENGINE_H
     17 #include "AudioOut.h"
     18 #include <string>
     19 #include <pthread.h>
     20 #include "ZynSema.h"
     21 #include "SafeQueue.h"
     22 
     23 namespace zyn {
     24 
     25 class WavFile;
     26 class WavEngine:public AudioOut
     27 {
     28     public:
     29         WavEngine(const SYNTH_T &synth);
     30         ~WavEngine();
     31 
     32         bool openAudio();
     33         bool Start();
     34         void Stop();
     35 
     36         void setAudioEn(bool /*nval*/) {}
     37         bool getAudioEn() const {return true; }
     38 
     39         void push(Stereo<float *> smps, size_t len);
     40 
     41         void newFile(WavFile *_file);
     42         void destroyFile();
     43 
     44     protected:
     45         void *AudioThread();
     46         static void *_AudioThread(void *arg);
     47 
     48     private:
     49         WavFile *file;
     50         ZynSema  work;
     51         SafeQueue<float> buffer;
     52 
     53         pthread_t *pThread;
     54 };
     55 
     56 }
     57 #endif