Nsound  0.9.4
Functions
Square.cc File Reference
#include <Nsound/Buffer.h>
#include <Nsound/Generator.h>
#include <Nsound/Square.h>
#include <cmath>
#include <cstring>
#include <cstdlib>
Include dependency graph for Square.cc:

Go to the source code of this file.

Functions

Buffer drawSquare (const float64 &sample_rate, const float64 &percent_lambda_1, const float64 &amplitude_1, const float64 &percent_lambda_2, const float64 &percent_lambda_3, const float64 &amplitude_3, const float64 &percent_lambda_4)
 

Function Documentation

Buffer drawSquare ( const float64 sample_rate,
const float64 percent_lambda_1,
const float64 amplitude_1,
const float64 percent_lambda_2,
const float64 percent_lambda_3,
const float64 amplitude_3,
const float64 percent_lambda_4 
)

Definition at line 41 of file Square.cc.

References Nsound::Generator::drawLine().

Referenced by Nsound::Square::Square().

49 {
50  Buffer waveform;
51 
52  // 1----2
53  // | |
54  // | |
55  // | |
56  // --1 2--3 4--5
57  // | |
58  // | |
59  // | |
60  // 3----4
61  //
62  // |-----lambda------|
63 
64  // Draw the 5 lines
65  Generator line(sample_rate);
66 
67  // Line 1
68  waveform << line.drawLine(percent_lambda_1, // pt1_time,
69  0.0,
70  0.0);
71  // Line 2
72  waveform << line.drawLine(percent_lambda_2 - percent_lambda_1, //pt2_time - pt1_time,
73  amplitude_1,
74  amplitude_1);
75  // Line 3
76  waveform << line.drawLine(percent_lambda_3 - percent_lambda_2, //pt3_time - pt2_time,
77  0.0,
78  0.0);
79  // Line 4
80  waveform << line.drawLine(percent_lambda_4 - percent_lambda_3, //pt4_time - pt3_time,
81  amplitude_3,
82  amplitude_3);
83  // Line 5
84  waveform << line.drawLine(1.0 - percent_lambda_4, //pt5_time - pt4_time,
85  0.0,
86  0.0);
87 
88  return waveform;
89 }
A Buffer for storing audio samples.
Definition: Buffer.h:60
A class the provides draw utilities and a wavetable oscillator.
Definition: Generator.h:50