Skip to content
Browse files

added warning utility function, working on shapes and sounds

  • Loading branch information...
1 parent e444c21 commit 771f7b4bc2317bbb4f8757704ffbde324197eaeb @bmuller committed Jun 11, 2009
View
9 blobber/application.cpp
@@ -18,6 +18,7 @@
#include "application.h"
#include <gtkmm/main.h>
+#include <exception>
namespace blobber {
using namespace std;
@@ -108,8 +109,12 @@ namespace blobber {
debug("loading canceled - module already loaded");
} else {
mi->set_config(config);
- mi->init(win.area, proj);
- mods.push_back(mi);
+ try {
+ mi->init(win.area, proj);
+ mods.push_back(mi);
+ } catch(exception &e) {
+ error("Could not initialize module " + mi->name + ". Error was: " + e.what());
+ }
}
};
View
4 blobber/mod_utils/movable_circle.cpp
@@ -45,9 +45,7 @@ namespace blobber {
void MovableCircle::clear(ProjectionWindow &pw) {
// no idea why small single pixel border left when clearing
- radius+=2;
- MovableObject::clear(pw);
- radius-=1;
+ pw.draw_circle(center, radius+1, background, true);
};
};
View
8 blobber/mod_utils/movable_crosshairs.cpp
@@ -43,8 +43,10 @@ namespace blobber {
void MovableCrosshairs::clear(ProjectionWindow &pw) {
// no idea why small single pixel border left when clearing
- size+=2;
- MovableObject::clear(pw);
- size-=2;
+ size += 4;
+ int hsize = size / 2;
+ pw.draw_line(COORD(center.x-hsize, center.y), COORD(center.x+hsize, center.y), background);
+ pw.draw_line(COORD(center.x, center.y-hsize), COORD(center.x, center.y+hsize), background);
+ size -= 4;
};
};
View
8 blobber/mod_utils/movable_square.cpp
@@ -43,9 +43,11 @@ namespace blobber {
void MovableSquare::clear(ProjectionWindow &pw) {
// no idea why small single pixel border left when clearing a box
- size+=2;
- MovableObject::clear(pw);
- size-=2;
+ size+=4;
+ int hsize = size / 2;
+ COORD topleft((center.x-hsize), (center.y-hsize));
+ pw.draw_box(topleft, size, size, background, true);
+ size-=4;
};
};
View
2 blobber/projection_window.cpp
@@ -205,6 +205,8 @@ namespace blobber {
if(need_alignment)
draw_alignment_graphics();
+
+ clear();
return true;
};
View
7 blobber/utils.cpp
@@ -22,6 +22,8 @@
#include <cstdlib>
#include <iostream>
+#include <gtkmm/messagedialog.h>
+
namespace blobber {
using namespace std;
@@ -38,6 +40,11 @@ namespace blobber {
#endif
};
+ void error(string msg) {
+ Gtk::MessageDialog md(msg, false, Gtk::MESSAGE_WARNING);
+ md.run();
+ };
+
/** convert integer to string */
void num_to_string(int i, string& s) {
char c_int[100];
View
1 blobber/utils.h
@@ -8,6 +8,7 @@ namespace blobber {
using namespace std;
void debug(string msg);
+ void error(string msg);
void num_to_string(int i, string& s);
void num_to_string(double i, string& s);
int string_to_int(string s);
View
5 modules/movable_shapes/movable_shapes.cpp
@@ -77,13 +77,13 @@ void MovableShapes::update(Camarea &area, ProjectionWindow &pw) {
return;
}
+ xhairs.move(poi[0].coord, pw);
+
// clear selected attr if we've missed the laser for 3 or more iterations;
if(missing_point_count > 3) {
for(unsigned int i=0; i<shapes.size(); i++)
shapes[i]->selected = false;
xhairs.move(poi[0].coord, pw);
- } else {
- xhairs.move(poi[0].coord, pw, false);
}
missing_point_count = 0;
@@ -107,6 +107,7 @@ void MovableShapes::update(Camarea &area, ProjectionWindow &pw) {
// could be a new selection - but only one can be selected
if(!isselected) {
for(unsigned int i=0; i<shapes.size(); i++) {
+ shapes[i]->paint(pw);
// only one new one can be selected
if((shapes[i]->selected = shapes[i]->in_bounds(poi[0].coord)))
break;
View
16 modules/shapesnsounds/shapesnsounds.cpp
@@ -40,8 +40,10 @@ int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
/////////////////////////////////////////////////////////////////////
-ShapesNSounds::ShapesNSounds() : ModInterface("ShapesNSounds", "Participatory music making module"), missing_counter(0) {
+ShapesNSounds::ShapesNSounds() : ModInterface("ShapesNSounds", "ShapesNSounds music making module"), note_is_on(false), missing_counter(0) {
// can't do much here cause we can't open a device until we're inited
+ lastpoint.x = 0;
+ lastpoint.y = 0;
};
@@ -70,9 +72,9 @@ void ShapesNSounds::init(Camarea &area, ProjectionWindow &pw) {
data.instrument = new BeeThree();
} catch ( RtError& error ) {
error.printMessage();
- throw ModuleRuntimeException("Could not open audio stream for Theremin module");
+ throw ModuleRuntimeException("Could not open audio stream for ShapesNSounds module");
} catch ( StkError & ) {
- throw ModuleRuntimeException("Could not open audio stream for Theremin module");
+ throw ModuleRuntimeException("Could not open audio stream for ShapesNSounds module");
}
};
@@ -105,7 +107,7 @@ void ShapesNSounds::note_on(double frequency) {
};
-void Theremin::note_off() {
+void ShapesNSounds::note_off() {
if(!note_is_on) return;
mod_debug("Note off");
data.instrument->noteOff(0.5);
@@ -114,12 +116,12 @@ void Theremin::note_off() {
};
-void Theremin::projection_window_exposed(ProjectionWindow &pw) {
+void ShapesNSounds::projection_window_exposed(ProjectionWindow &pw) {
pw.get_drawing_area_dimensions(dimensions);
};
-void Theremin::update(Camarea &area, ProjectionWindow &pw) {
+void ShapesNSounds::update(Camarea &area, ProjectionWindow &pw) {
BVector<PIXEL> poi;
get_poi(area, poi);
@@ -141,6 +143,6 @@ void Theremin::update(Camarea &area, ProjectionWindow &pw) {
extern "C" {
ModInterface *get_module() {
- return new Theremin();
+ return new ShapesNSounds();
};
};
View
8 modules/shapesnsounds/shapesnsounds.h
@@ -4,7 +4,7 @@
using namespace blobber;
-// The TickData structure holds all the class instances and data that
+// The TickData structure holds all the class instances and data that
// are shared by the various processing functions.
struct TickData {
Instrmnt *instrument;
@@ -13,18 +13,24 @@ struct TickData {
};
+
class ShapesNSounds : public ModInterface {
public:
ShapesNSounds();
~ShapesNSounds();
void projection_window_exposed(ProjectionWindow &pw);
void update(Camarea &area, ProjectionWindow &pw);
void init(Camarea &area, ProjectionWindow &pw);
+ void note_on(double frequency);
+ void note_off();
protected:
+ DIMENSION dimensions;
+ COORD lastpoint;
float min_frequency, max_frequency;
int missing_counter;
RtAudio dac;
TickData data;
+ bool note_is_on;
RtAudio::StreamParameters parameters;
unsigned int bufferFrames;
};

0 comments on commit 771f7b4

Please sign in to comment.
Something went wrong with that request. Please try again.