Pd++  0.01
A pure C++ implementation of Pure Data objects
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
SoundFiler.h
1 /*
2  SoundFiler.cpp
3  Pd++
4 
5  Created by Esler,Robert Wadhams on 10/1/14.
6  Copyright (c) 2014 Robert Esler. All rights reserved.
7 
8  Some of the code in Pd++ is Copyright (c) 1997-1999 Miller Puckette.
9  For information on usage and redistribution, and for a DISCLAIMER OF ALL
10  WARRANTIES, see the file, "LICENSE.txt," in this distribution.
11 */
12 
13 #ifndef __Pd____SoundFiler__
14 #define __Pd____SoundFiler__
15 
16 #include <string>
17 #include <vector>
18 #include "FileWvIn.h"
19 #include "FileWrite.h"
20 #include "Stk.h"
21 #include "PdMaster.h"
22 
23 namespace pd {
24 
25 
26 /*! \brief Reads and writes sound files.
27 
28  Instead of trying to detach the Pd soundfiler code, which is very difficult to
29  port over to C++ due to the number of dependencies, I chose to use STK's
30  read and write methods. Since their classes are already written in C++ this saves a lot of
31  time and really shouldn't sound any different.
32 
33  This does not apply to table reading, such as tabwrite4~, which uses interpolation.
34  When reading from arrays into the audio domain we will still use this method.
35 
36 */
37 
38 class SoundFiler : public PdMaster, public stk::Stk {
39 
40 private:
41  stk::StkFrames array; //generic array used for input
42  std::vector<double> soundFileData; //this is the actual input data as a vector
43  stk::FileWvIn input;
44 
45  void setArray(std::vector<double> );
46 
47 public:
48  SoundFiler();
49  ~SoundFiler();
50  double read(std::string file);
51  void write(std::string fileName,
52  unsigned int nChannels,
53  stk::FileWrite::FILE_TYPE type,
54  Stk::StkFormat format,
55  std::vector<double> array);
56 
57  std::vector<double> getArray() {return soundFileData;};
58 
59  const std::string pdName = "soundfiler";
60 
61 };
62 
63 } //pd namespace
64 #endif /* defined(__Pd____SoundFiler__) */
Reads and writes sound files.
Definition: SoundFiler.h:38
The Pd++ namespace.
Definition: BandPass.cpp:14
STK audio file input class.
Definition: FileWvIn.h:42
A super class inherited by all Pd++ objects.
Definition: PdMaster.h:62
double read(std::string file)
Definition: SoundFiler.cpp:40
An STK class to handle vectorized audio data.
Definition: Stk.h:272
STK base class.
Definition: Stk.h:132
void write(std::string fileName, unsigned int nChannels, stk::FileWrite::FILE_TYPE type, Stk::StkFormat format, std::vector< double > array)
Definition: SoundFiler.cpp:93