Nsound  0.9.4
test_mesh.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: test_mesh.cc 874 2014-09-08 02:21:29Z weegreenblobbie $
4 //
5 // Copyright (c) 2008-Present Nick Hilton
6 //
7 // weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
8 //
9 //-----------------------------------------------------------------------------
10 
11 //-----------------------------------------------------------------------------
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation; either version 2 of the License, or
16 // (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Library General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 //
27 //-----------------------------------------------------------------------------
28 
29 #include <Nsound/NsoundAll.h>
30 
31 #include "Test.h"
32 
33 #include <cmath>
34 #include <iostream>
35 #include <sstream>
36 
37 using namespace Nsound;
38 
39 using std::cerr;
40 using std::cout;
41 using std::endl;
42 using std::flush;
43 
44 static const char * THIS_FILE = "test_mesh.cc";
45 
46 int main(int argc, char ** argv)
47 {
48 //~ for(int x = 3; x <= 19; x += 4)
49 //~ {
50 //~ for(float64 leak = 0.87; leak <= 0.99; leak += 0.06)
51 //~ {
52 //~ for(float64 tau = 0.005; tau <= 0.16; tau *= 2.0)
53 //~ {
54 //~ char buffer[1024];
55 //~
56 //~ sprintf(buffer, "mesh_x%02d_y19_leak%4.2f_tau%5.3f.wav",
57 //~ x,
58 //~ leak,
59 //~ tau);
60 //~
61 //~ cout << "writing " << buffer;
62 //~
63 //~ Mesh2D mesh(44100.0, x, 19, leak, tau);
64 //~
65 //~ Buffer hit = mesh.strike(0.25, 0.25, 1.0);
66 //~
67 //~ Buffer output;
68 //~
69 //~ output << hit << hit << hit;
70 //~ output.normalize();
71 //~
72 //~ output *= 0.8;
73 //~
74 //~ output >> buffer;
75 //~
76 //~ cout << endl;
77 //~
78 //~ }
79 //~ }
80 //~ }
81 
82  // sr x y leak tau
83  Mesh2D mesh(44100.0, 11, 19, 0.88, 0.010);
84 
85  Buffer output;
86 
87  output << mesh.strike(0.333, 0.333, 3.0);
88 
89  output.normalize();
90 
91  output >> "mesh.wav";
92 
93  return 0;
94 }
95 
96 
Buffer strike(const Buffer &x_pos, const Buffer &y_pos, const Buffer &velocity)
Hit the mesh many times at different locations.
Definition: Mesh2D.cc:249
int main(int argc, char **argv)
Definition: test_mesh.cc:46
void normalize()
Multiplies the Buffer by a constant gain so the peak sample has magnitude 1.0.
Definition: Buffer.cc:1064
A Buffer for storing audio samples.
Definition: Buffer.h:60
static const char * THIS_FILE
Definition: test_mesh.cc:44