Nsound  0.9.4
DrumKickBass.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: DrumKickBass.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) 2006-Present Nick Hilton
11 //
12 // Simulates a bass kick drum. Based on a Csound drum.
13 //
14 // source: http://www.adp-gmbh.ch/csound/instruments/base_drum01.html
15 //
16 //-----------------------------------------------------------------------------
17 
18 //-----------------------------------------------------------------------------
19 //
20 // This program is free software; you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation; either version 2 of the License, or
23 // (at your option) any later version.
24 //
25 // This program is distributed in the hope that it will be useful,
26 // but WITHOUT ANY WARRANTY; without even the implied warranty of
27 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 // GNU Library General Public License for more details.
29 //
30 // You should have received a copy of the GNU General Public License
31 // along with this program; if not, write to the Free Software
32 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 //
34 //-----------------------------------------------------------------------------
35 
36 #ifndef _NSOUND_DRUM_KICK_BASS_H_
37 #define _NSOUND_DRUM_KICK_BASS_H_
38 
39 #include <Nsound/Instrument.h>
40 
41 namespace Nsound
42 {
43 
44 // Forward Declarations
45 class AudioStream;
46 class Buffer;
47 
48 //-----------------------------------------------------------------------------
50 class DrumKickBass : public Instrument
51 {
52  public:
53 
56  const float64 & sample_rate,
57  const float64 & high_frequency,
58  const float64 & low_frequency);
59 
61  ~DrumKickBass();
62 
64  AudioStream play();
65 
67  AudioStream play(const float64 & duration, const float64 & frequency);
68 
71  const float64 & duration,
72  const float64 & high_frequency,
73  const float64 & low_frequency);
74 
77  const float64 & duation,
78  const Buffer & high_frequency,
79  const Buffer & low_frequency);
80 
82  std::string getInfo()
83  {
84  return
85  "Nsound::DrumKickBass by Nick Hilton on 2008-10-14\n"
86  "Simulates a bass kick drum. Based on a Csound drum.\n"
87  "source: http://www.adp-gmbh.ch/csound/instruments/base_drum01.html\n\n"
88  "sr = 48000\n"
89  "ksmps = 32\n"
90  "nchnls = 2\n"
91  "\n"
92  "instr 1\n"
93  " i_len = p3+0.2\n"
94  "\n"
95  " icps = 51\n"
96  " iamp = 1\n"
97  "\n"
98  " kcps expon 1, 0.022, 0.5\n"
99  " kcps = 4.3333 * kcps * icps + icps\n"
100  "\n"
101  " a1 phasor kcps\n"
102  " a2 phasor kcps, 0.5\n"
103  " a1 = a1 - a2\n"
104  "\n"
105  " kffrq1 expon 1, 0.07, 0.5\n"
106  " kffrq2 expon 1, 0.01, 0.5\n"
107  " kffrq = (kffrq1 + kffrq2) * kcps\n"
108  "\n"
109  " a1 pareq a1, kffrq, 0, 0.7071, 2\n"
110  "\n"
111  " a1 = taninv(a1 * 20)\n"
112  "\n"
113  " a1 pareq a1, kcps * 6, 2, 1, 2\n"
114  " a1 pareq a1, icps * 1.25, 2.5, 1, 0\n"
115  "\n"
116  " a2 linseg 1, i_len, 1, 0.01, 0, 1, 0\n"
117  " a1 = a1 * a2 * iamp * 4500 + (1/1e24)\n"
118  "\n"
119  " outs a1,a1\n"
120  "endin\n";
121  };
122 
123  protected:
124 
125  float64 hi_f_;
127 
128 };
129 
130 };
131 
132 // :mode=c++: jEdit modeline
133 #endif
AudioStream play()
Plays a demo for this instrument.
Definition: DrumKickBass.cc:57
double float64
Definition: Nsound.h:146
DrumKickBass(const float64 &sample_rate, const float64 &high_frequency, const float64 &low_frequency)
Creates a Bass Kick Drum.
Definition: DrumKickBass.cc:42
~DrumKickBass()
Destructor.
Definition: DrumKickBass.cc:53
std::string getInfo()
Nsound::DrumKickBass information.
Definition: DrumKickBass.h:82
The Nsound Instrument baseclass. All Nsound instruments extend this class.
Definition: Instrument.h:50
A Buffer for storing audio samples.
Definition: Buffer.h:60