Nsound  0.9.4
Public Member Functions | Protected Attributes | List of all members
Nsound::DrumKickBass Class Reference

Class Drum. More...

#include <Nsound/DrumKickBass.h>

Inheritance diagram for Nsound::DrumKickBass:
Inheritance graph
[legend]

Public Member Functions

 DrumKickBass (const float64 &sample_rate, const float64 &high_frequency, const float64 &low_frequency)
 Creates a Bass Kick Drum. More...
 
 ~DrumKickBass ()
 Destructor. More...
 
AudioStream play ()
 Plays a demo for this instrument. More...
 
AudioStream play (const float64 &duration, const float64 &frequency)
 Plays a static note for this instrument. More...
 
AudioStream play (const float64 &duration, const float64 &high_frequency, const float64 &low_frequency)
 Static play method. More...
 
AudioStream play (const float64 &duation, const Buffer &high_frequency, const Buffer &low_frequency)
 Dynamic play method. More...
 
std::string getInfo ()
 Nsound::DrumKickBass information. More...
 

Protected Attributes

float64 hi_f_
 
float64 lo_f_
 
float64 sample_rate_
 

Detailed Description

Class Drum.

Definition at line 50 of file DrumKickBass.h.

Constructor & Destructor Documentation

DrumKickBass::DrumKickBass ( const float64 sample_rate,
const float64 high_frequency,
const float64 low_frequency 
)

Creates a Bass Kick Drum.

Definition at line 42 of file DrumKickBass.cc.

46  :
47  Instrument(sample_rate),
48  hi_f_(high_frequency),
49  lo_f_( low_frequency){}
Instrument(const float64 &sample_rate)
Definition: Instrument.h:54
DrumKickBass::~DrumKickBass ( )

Destructor.

Definition at line 53 of file DrumKickBass.cc.

53 {}

Member Function Documentation

AudioStream DrumKickBass::play ( )
virtual

Plays a demo for this instrument.

Implements Nsound::Instrument.

Definition at line 57 of file DrumKickBass.cc.

References play(), and Nsound::Instrument::sample_rate_.

Referenced by my_main(), and play().

58 {
60 
61  y << play(0.6, 120.0, 51.0)
62  << play(0.6, 120.0, 51.0)
63  << play(0.6, 120.0, 51.0)
64  << play(0.6, 120.0, 51.0);
65 
66  return y;
67 }
AudioStream play()
Plays a demo for this instrument.
Definition: DrumKickBass.cc:57
float64 sample_rate_
Definition: Instrument.h:76
AudioStream DrumKickBass::play ( const float64 duration,
const float64 frequency 
)
virtual

Plays a static note for this instrument.

Implements Nsound::Instrument.

Definition at line 71 of file DrumKickBass.cc.

References lo_f_, and play().

74 {
75  return play(duration, frequency, lo_f_);
76 }
AudioStream play()
Plays a demo for this instrument.
Definition: DrumKickBass.cc:57
AudioStream DrumKickBass::play ( const float64 duration,
const float64 high_frequency,
const float64 low_frequency 
)

Static play method.

Definition at line 81 of file DrumKickBass.cc.

References Nsound::Generator::drawDecay(), Nsound::Generator::drawLine(), Nsound::FilterParametricEqualizer::filter(), Nsound::Generator::generate(), Nsound::AudioStream::getLength(), Nsound::FilterParametricEqualizer::HIGH_SHELF, and Nsound::Instrument::sample_rate_.

85 {
86  Square square(sample_rate_);
87 
88  Buffer signal_freqs = 2.333 * hi_freq * square.drawDecay(0.08, 7.0)
89  + low_freq
90  << square.drawLine(duration - 0.08, low_freq, low_freq);
91 
92  Buffer signal = -0.5 * square.generate(duration, signal_freqs) << 0.0;
93 
94 
95  Buffer filter_freqs = 0.8*square.drawDecay(duration * 0.5, 7.0) + 0.2
96  << square.drawLine(duration * 0.5, 0.2, 0.0);
97 
98  filter_freqs *= 2.0 * signal_freqs;
99 
102  sample_rate_, filter_freqs[0], 0.7071, 0.0);
103 
106  sample_rate_, signal_freqs[0] * 3.0, 1.0, 2.0);
107 
110  sample_rate_, low_freq * 1.25, 1.0, 2.5);
111 
113 
114  y = f1.filter(signal, filter_freqs);
115 
116  for(uint32 i = 0; i < y.getLength(); ++i)
117  {
118  y[0][1] = std::atan(y[0][i] * 20.0);
119  }
120 
121  y = f2.filter(y, signal_freqs * 3.0);
122 
123  y = f3.filter(y) * 0.56;
124 
125  return y;
126 }
Implementation of Zoelzer's parametric equalizer filters, with some modifications by the author...
unsigned int uint32
Definition: Nsound.h:153
Square generator.
Definition: Square.h:50
float64 sample_rate_
Definition: Instrument.h:76
A Buffer for storing audio samples.
Definition: Buffer.h:60
AudioStream DrumKickBass::play ( const float64 duation,
const Buffer high_frequency,
const Buffer low_frequency 
)

Dynamic play method.

Definition at line 130 of file DrumKickBass.cc.

References play().

134 {
135 
136  // FIXME FIXME FIXME FIXME, this is not dynamic!
137  return play(duration, high_frequency[0], low_frequency[0]);
138 
139 }
AudioStream play()
Plays a demo for this instrument.
Definition: DrumKickBass.cc:57
std::string Nsound::DrumKickBass::getInfo ( )
inlinevirtual

Nsound::DrumKickBass information.

Implements Nsound::Instrument.

Definition at line 82 of file DrumKickBass.h.

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  };

Member Data Documentation

float64 Nsound::DrumKickBass::hi_f_
protected

Definition at line 121 of file DrumKickBass.h.

float64 Nsound::DrumKickBass::lo_f_
protected

Definition at line 126 of file DrumKickBass.h.

Referenced by play().

float64 Nsound::Instrument::sample_rate_
protectedinherited

The documentation for this class was generated from the following files: