40 using namespace Nsound;
57 sample_rate_(sample_rate),
60 leak_gain_(leak_gain),
261 output <<
tick(x_pos[i % x_size], y_pos[i % y_size], velocity[i]);
276 std::stringstream ss;
280 FILE * f_out = fopen(ss.str().c_str(),
"w");
284 M_THROW(
"Unable to open '" << ss.str().c_str() <<
"' for writing.");
288 for(
int32 y =
Y_ - 1; y >= 0; --y)
292 if(
mesh(x,y) != NULL)
294 fprintf(f_out,
" %5d", x + y * X_);
298 fprintf(f_out,
" -1");
301 fprintf(f_out,
"\n");
316 std::stringstream ss;
320 FILE * f_out = fopen(ss.str().c_str(), mode.c_str());
324 M_THROW(
"Unable to open '" << ss.str().c_str() <<
"' for writing.");
328 for(
int32 y =
Y_ - 1; y >= 0; --y)
332 fprintf(f_out,
"%6.3f ",
mesh(x,y)->getVelocity());
335 fprintf(f_out,
"\n");
343 const std::string & dirname,
344 const std::string & prefix)
362 output <<
tick(x_pos, y_pos, velocity);
367 for(
uint32 i = 0; i < 44100; ++i)
369 output <<
tick(x_pos, y_pos, 0.0);
381 return output * attack;
394 float64 x_strike = x_pos * x_max;
395 float64 y_strike = y_pos * y_max;
401 x_strike = 0.5 / 3.0;
402 y_strike = 0.5 / 3.0;
417 float64 power = velocity * std::exp(-200.0 * (xx + yy));
Mesh2D(const float64 &sample_rate, uint32 width, uint32 height, const float64 &leak_gain, const float64 &tau, const float64 &delta=6.0, const float64 &gamma=8.0)
Constructor.
float64 getEnergy() const
Calculate total energy in the mesh.
void updateVelocity()
updates junction velocity.
void strike(const float64 &velocity)
Adds velocity to this junction.
Buffer strike(const Buffer &x_pos, const Buffer &y_pos, const Buffer &velocity)
Hit the mesh many times at different locations.
float64 gamma_
MeshJunction delta.
void clear()
Clears all MeshJunctions to zero.
void setNeighborNorth(MeshJunction *ptr)
void setMeshDumping(boolean flag, const std::string &dirname=".", const std::string &prefix="mesh")
Enables the dumping of mesh values to disk for use with mesh2blender.py.
void allocMemory()
Allocates memory for the mesh.
void writeMeshMap()
Write to disk the mesh map, used with mesh2blender.py.
void freeMemory()
Frees memory from the mesh.
uint32 Y_
The number of MeshJunctions columns.
Mesh2D & operator=(const Mesh2D &rhs)
Assignment operator.
void setNeighborEast(MeshJunction *ptr)
uint32 getLength() const
Returns the number of samples in the Buffer.
float64 tau_
MeshJunction leak gain.
void setNeighborSouth(MeshJunction *ptr)
boolean dump_mesh_
Center MeshJunction where final sound is collected.
MeshJunction * center_
Array of pointers.
float64 leak_gain_
The number of MeshJunctions rows.
void writeMeshFile(const std::string &mode)
MeshJunction ** mesh_
MeshJunction gamma.
float64 delta_
MeshJunction tau.
void setNeighborWest(MeshJunction *ptr)
float64 getVelocity() const
A Buffer for storing audio samples.
MeshJunction * mesh(uint32 x, uint32 y)
Buffer drawLine(const float64 &duration, const float64 &litude_start, const float64 &litude_finish) const
This method draws a linear line beteween 2 points.
void saveState()
Saves previous south and east velocities.
void clear()
Clears all velicityes in the junctino.
A class the provides draw utilities and a wavetable oscillator.
float64 tick(const float64 &x_pos, const float64 &y_pos, const float64 &velocity)
Calculate one sample.