This GitLab instance reached the end of its service life. It won't be possible to create new users or projects.

Please read the deprecation notice for more information concerning the deprecation timeline

Visit migration.git.tu-berlin.de (internal network only) to import your old projects to the new GitLab platform 📥

Commit 99fe7636 by Henrik von Coler

Changed exception handling in granular example!

parent 309b375c
...@@ -20,7 +20,13 @@ GranularExample::GranularExample(std::string filename, int win_size, int nWindow ...@@ -20,7 +20,13 @@ GranularExample::GranularExample(std::string filename, int win_size, int nWindow
{ {
// creating an OSC manager instance // creating an OSC manager instance
oscman = new OscMan(5111); try{
oscman = new OscMan(5111);
}
catch(int e)
{
cout << "Bad Port!";
}
this->client = jack_client_open("Grain_Example", JackNullOption, &status, NULL); this->client = jack_client_open("Grain_Example", JackNullOption, &status, NULL);
...@@ -74,7 +80,7 @@ int GranularExample::process (jack_nframes_t nframes) ...@@ -74,7 +80,7 @@ int GranularExample::process (jack_nframes_t nframes)
// loop over all samples of output buffer // loop over all samples of output buffer
for(int sampCNT=0; sampCNT<nframes; sampCNT++) for(int sampCNT=0; sampCNT<nframes; sampCNT++)
{ {
out[0][sampCNT] = grainer->get_sample(); out[0][sampCNT] = grainer->get_sample();
} }
return 0; return 0;
} }
......
...@@ -21,15 +21,14 @@ OscMan::OscMan(int p) ...@@ -21,15 +21,14 @@ OscMan::OscMan(int p)
speed = 0; speed = 0;
try st = new lo::ServerThread(port);
{
st = new lo::ServerThread(port); if (st->is_valid())
}
catch (int e)
{ {
std::cout << "Possibly a bad port!" << std::endl;
}
// Add the example handler to the server! // Add the example handler to the server!
st->add_method("/speed", "f", speed_callback, this); st->add_method("/speed", "f", speed_callback, this);
...@@ -37,11 +36,15 @@ OscMan::OscMan(int p) ...@@ -37,11 +36,15 @@ OscMan::OscMan(int p)
st->start(); st->start();
std::cout << "Started OSC Server!" << std::endl; std::cout << "Started OSC Server!" << std::endl;
}
else
throw std::invalid_argument("OSC server not started - possibly a bad port!");
} }
int OscMan::speed_callback(const char *path, const char *types, lo_arg ** argv, int OscMan::speed_callback(const char *path, const char *types, lo_arg ** argv,
int argc, void *data, void *user_data ) int argc, void *data, void *user_data )
{ {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include<iostream> #include<iostream>
#include<vector> #include<vector>
#include<string> #include<string>
#include <stdexcept>
class OscMan class OscMan
......
...@@ -20,3 +20,4 @@ wav_example: main.o wav_example.o oscman.o singlesample.o ...@@ -20,3 +20,4 @@ wav_example: main.o wav_example.o oscman.o singlesample.o
clean: clean:
rm *.o wav_example rm *.o wav_example
#!/bin/sh
g++ -std=c++11 gain_example.cpp oscman.cpp -ljack -llo -o gain_example
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment