Nsound  0.9.4
Clarinet.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: Clarinet.h 874 2014-09-08 02:21:29Z weegreenblobbie $
4 //
5 // Nsound is a C++ library and Python module for audio synthesis featuring
6 // dynamic digital filters. Nsound lets you easily shape waveforms and write
7 // to disk or plot them. Nsound aims to be as powerful as Csound but easy to
8 // use.
9 //
10 // Copyright (c) 2009-Present Nick Hilton
11 //
12 // Based on physical models written in Csound by Hans Mikelson.
13 //
14 //-----------------------------------------------------------------------------
15 
16 //-----------------------------------------------------------------------------
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 // This program is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU Library General Public License for more details.
27 //
28 // You should have received a copy of the GNU General Public License
29 // along with this program; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 //
32 //-----------------------------------------------------------------------------
33 
34 #ifndef _NSOUND_CLARINET_H_
35 #define _NSOUND_CLARINET_H_
36 
37 #include <Nsound/Instrument.h>
38 
39 namespace Nsound
40 {
41 
42 // Forward Declarations
43 class AudioStream;
44 class Buffer;
45 
46 //-----------------------------------------------------------------------------
48 class Clarinet : public Instrument
49 {
50  public:
51 
53  Clarinet(const float64 & sample_rate);
54 
56  ~Clarinet();
57 
59  AudioStream play();
60 
62  AudioStream play(const float64 & duration, const float64 & frequency);
63 
66  const float64 & duration,
67  const float64 & frequency,
68  const float64 & presure,
69  const float64 & filter,
70  const float64 & reed_stiffness);
71 
73  std::string getInfo()
74  {
75  return
76  "Nsound::Clarinet by Nick Hilton\n\n"
77 
78  "Based on physical models written in Csound by Hans Mikelson.\n"
79  "Originally based on Perry Cook's physical model.\n\n"
80 
81  ";PERRY COOK'S CLARINET\n"
82  "\n"
83  " instr 5\n"
84  "asum2 init 0\n"
85  "abellreed init 0\n"
86  "aout init 0\n"
87  "kenv1 linseg 0, .005, .55 + .3*p4, p3 - .015, .55 + .3*p4, .01, 0\n"
88  "\n"
89  "; REED SECTION\n"
90  "apressm = kenv1\n"
91  "arefilt tone abellreed, 1500\n"
92  "asum2 = (-.95)*arefilt - apressm\n"
93  "areedtab tablei asum2/4+.34, 1, 1, .5\n"
94  "\n"
95  "abellreed delayr 1/p5/2\n"
96  " delayw aout\n"
97  "aout delayr 1/p5/2\n"
98  " delayw apressm + areedtab*asum2\n"
99  "\n"
100  " out aout*10000\n"
101  " endin;\n";
102  };
103 
104 };
105 
106 };
107 
108 // :mode=c++: jEdit modeline
109 #endif
AudioStream play()
Plays a demo for this instrument.
Definition: Clarinet.cc:56
Class Drum.
Definition: Clarinet.h:48
double float64
Definition: Nsound.h:146
std::string getInfo()
Nsound::Clarinet information.
Definition: Clarinet.h:73
Clarinet(const float64 &sample_rate)
Creates a Bass Kick Drum.
Definition: Clarinet.cc:42
The Nsound Instrument baseclass. All Nsound instruments extend this class.
Definition: Instrument.h:50
~Clarinet()
Destructor.
Definition: Clarinet.cc:50