diff options
author | John Glover <glover.john@gmail.com> | 2011-09-02 13:31:17 +0100 |
---|---|---|
committer | John Glover <glover.john@gmail.com> | 2011-09-02 13:31:17 +0100 |
commit | 5faf04f32f7735b21f261d18cf32f9079cf1456a (patch) | |
tree | fc477521bd34ac5d28244ba1e6f388a579251b40 | |
parent | 3328e479fda1ecd36ce7b4825351a46b2d01c8e7 (diff) | |
download | simpl-5faf04f32f7735b21f261d18cf32f9079cf1456a.tar.gz simpl-5faf04f32f7735b21f261d18cf32f9079cf1456a.tar.bz2 simpl-5faf04f32f7735b21f261d18cf32f9079cf1456a.zip |
Rename common.i to base.i
-rw-r--r-- | simpl/base.i | 75 | ||||
-rw-r--r-- | simpl/common.i | 27 |
2 files changed, 75 insertions, 27 deletions
diff --git a/simpl/base.i b/simpl/base.i new file mode 100644 index 0000000..53efa29 --- /dev/null +++ b/simpl/base.i @@ -0,0 +1,75 @@ +%{ + #include "../src/simpl/base.h" + #include "../src/simpl/exceptions.h" + #include <vector> + #define SWIG_FILE_WITH_INIT +%} + +%include exception.i +%include typemaps.i +%include std_string.i +%include std_vector.i +%include std_list.i +%include "numpy.i" + +%init +%{ + import_array(); +%} + +%template(DoubleVector) std::vector<Simpl::number>; + +%include "../src/simpl/base.h" +%include "../src/simpl/exceptions.h" + +%exception +{ + try + { + $action + } + catch(Simpl::Exception & ex) + { + std::string s("Simpl exception: "); + s.append(ex.what()); + SWIG_exception(SWIG_UnknownError, (char *) s.c_str()); + } + catch(std::exception & ex) + { + std::string s("std C++ exception: "); + s.append(ex.what()); + SWIG_exception(SWIG_UnknownError, (char *) s.c_str()); + } +} + +%extend Simpl::Frame +{ + Simpl::samples get_audio() + { + if($self->audio()) + { + /* const Simpl::samples* sp = $self->audio(); */ + /* std::cout << sp->at(0) << std::endl; */ + + /* Simpl::samples s = Simpl::samples(*($self->audio())); */ + /* return s; */ + return Simpl::samples(512, 0.5); + } + else + { + return Simpl::samples($self->size(), 0.00); + } + } + + void set_audio(const samples& new_audio) + { + $self->audio(new_audio); + } + + %pythoncode + %{ + __swig_getmethods__["audio"] = get_audio + __swig_setmethods__["audio"] = set_audio + if _newclass: audio = property(get_audio, set_audio) + %} +}; diff --git a/simpl/common.i b/simpl/common.i deleted file mode 100644 index 12781a4..0000000 --- a/simpl/common.i +++ /dev/null @@ -1,27 +0,0 @@ -%include exception.i -%include std_string.i -%include std_vector.i -%include std_list.i -%include "numpy.i" - -%template(DoubleVector) std::vector<Simpl::number>; - -%exception -{ - try - { - $action - } - catch(Simpl::Exception & ex) - { - std::string s("Simpl exception: "); - s.append(ex.what()); - SWIG_exception(SWIG_UnknownError, (char *) s.c_str()); - } - catch(std::exception & ex) - { - std::string s("std C++ exception: "); - s.append(ex.what()); - SWIG_exception(SWIG_UnknownError, (char *) s.c_str()); - } -} |