Nsound  0.9.4
GuitarBass.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: GuitarBass.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 // weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
13 //
14 // Based on physical models written in Csound by Hans Mikelson.
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_GUITAR_BASS_H_
37 #define _NSOUND_GUITAR_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 GuitarBass : public Instrument
51 {
52  public:
53 
55  GuitarBass(const float64 & sample_rate);
56 
58  ~GuitarBass();
59 
61  AudioStream play();
62 
64  AudioStream play(const float64 & duration, const float64 & frequency);
65 
67  std::string getInfo()
68  {
69  return
70  "Nsound::GuitarBass by Nick Hilton\n\n"
71 
72  "Based on physical models written in Csound by Hans Mikelson.\n\n"
73 
74  ";BASS PHYSICAL MODEL\n"
75  " instr 2\n"
76  "\n"
77  "; INITIALIZATIONS\n"
78  "ifqc = cpspch(p5)\n"
79  "kcount init 0\n"
80  "abody1 init 0\n"
81  "abody2 init 0\n"
82  "adline init 0\n"
83  "\n"
84  "; ENVELOPES\n"
85  ";**********\n"
86  "; FILTER ENVELOPE\n"
87  "kenvflt linseg 0, .01, 1, p3-.11, 1, .1, 0\n"
88  "; THIS ENVELOPE LOADS THE STRING WITH A TRIANGLE WAVE.\n"
89  "kenvstr linseg 0, 1/ifqc/8, -p4/2, 1/ifqc/4, p4/2, 1/ifqc/8, 0, p3-1/ifqc, 0\n"
90  "; THIS ENVELOPE IS FOR THE BODY RESONANCE\n"
91  "kenvres linseg 0, .1, 1, p3-.1, 1\n"
92  "\n"
93  "; DELAY LINE WITH FILTERED FEEDBACK\n"
94  "afiltr tone adline, ifqc*ifqc/10\n"
95  "adline delay afiltr + kenvstr, 1/ifqc\n"
96  "\n"
97  "; RESONANCE OF THE BODY\n"
98  "abody1 reson afiltr, 160, 40\n"
99  "abody2 reson afiltr, 80, 20\n"
100  "\n"
101  "aout = afiltr + .0001*kenvres*abody1 + .00004*kenvres*abody2\n"
102  " out aout * kenvflt\n"
103  " endin\n";
104  };
105 
106 };
107 
108 };
109 
110 // :mode=c++: jEdit modeline
111 #endif
~GuitarBass()
Destructor.
Definition: GuitarBass.cc:50
std::string getInfo()
Nsound::GuitarBass information.
Definition: GuitarBass.h:67
GuitarBass(const float64 &sample_rate)
Creates a Bass Kick Drum.
Definition: GuitarBass.cc:42
double float64
Definition: Nsound.h:146
AudioStream play()
Plays a demo for this instrument.
Definition: GuitarBass.cc:56
The Nsound Instrument baseclass. All Nsound instruments extend this class.
Definition: Instrument.h:50
Class Drum.
Definition: GuitarBass.h:50