Permalink
Browse files

Import artifastring 1.0.

  • Loading branch information...
gperciva committed Apr 1, 2011
1 parent c08122a commit 2d4861e073f7ce20e02384a470f25644d493ba17
View
@@ -0,0 +1,10 @@
+*.o
+*.pyc
+_violin_instrument.so
+violin_instrument.py
+violin_instrument_wrap.cxx
+_monowav.so
+monowav.py
+monowav_wrap.cxx
+html/
+actions2wav
View
675 COPYING

Large diffs are not rendered by default.

Oops, something went wrong.
View
1,551 Doxyfile

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,73 @@
+CPP=g++
+# FPIC required for swig
+CPPFLAGS = -O3 \
+ -FPIC \
+ -funroll-loops
+# -lboost_thread-mt
+
+#CPPFLAGS = -g -fbounds-check -Wall
+# -lboost_thread-mt
+
+
+### actual user targets
+all: actions2wav
+
+doc:
+ doxygen
+
+swig: _violin_instrument.so _monowav.so
+
+
+
+### internal setup
+
+VIOLIN_O = violin_instrument.o violin_string.o monowav.o
+
+%.o: %.cpp violin_constants.h violin_body_impulse.h monowav.h
+ $(CPP) -c $(CPPFLAGS) $< -o $@
+
+actions2wav: actions2wav.cpp $(VIOLIN_O)
+ g++ $(CPPFLAGS) $(VIOLIN_O) $< -o $@
+
+# I feel dirty for using these special symbols. Shouldn't have
+# used a Makefile for this. :(
+%_wrap.o: %.i
+ swig -c++ -python $<
+ g++ $(CPPFLAGS) -c $*_wrap.cxx \
+ -I/usr/include/python2.6
+
+_violin_instrument.so: violin_instrument_wrap.o $(VIOLIN_O)
+ g++ $(CPPFLAGS) -shared $< -o $@ \
+ violin_string.o violin_instrument.o
+
+_monowav.so: monowav_wrap.o $(VIOLIN_O)
+ g++ $(CPPFLAGS) -shared $< -o $@ \
+ monowav.o
+
+# you can change 512 to 128 or 2048.
+violin_body_impulse.h:
+ echo "// This file was automatically generated" > $@
+ echo "#ifndef IMPULSE_DATA_H" >> $@
+ echo "#define IMPULSE_DATA" >> $@
+ echo "const unsigned int PC_KERNEL_SIZE = 512;" >> $@
+ echo "const double pc_kernel[] = {" >> $@
+ sox impulses/impulse-512.wav -t dat - | \
+ awk '$$1 != ";" { print " ", $$2, ","}' >> $@
+ echo "};" >> $@
+ echo "#endif" >> $@
+
+.PHONY: clean
+clean:
+ # main stuff
+ rm -f actions2wav
+ rm -f *.o
+ rm -f *.pyc
+ # swig stuff
+ rm -f violin_instrument.py violin_instrument_wrap.cxx
+ rm -f _*.so
+ rm -f monowav.py monowav_wrap.cxx
+ rm -rf html/
+
+
+
+
View
@@ -0,0 +1 @@
+1.0
View
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2010 Graham Percival
+ * This file is part of Artifastring.
+ *
+ * Artifastring is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * Artifastring is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with Artifastring. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "violin_instrument.h"
+#include "monowav.h"
+
+// This file is ugly and stupid, but it works. And "if it's
+// stupid and it works, it's not stupid" -somebody.
+// So I guess this file is just ugly. :)
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <string>
+#include <vector>
+#include <fstream>
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+unsigned int total_samples;
+
+vector<string> gulp_file(const char *filename) {
+ vector<string> input;
+ input.clear();
+
+ string line;
+ ifstream input_file(filename, ios_base::in);
+ while (getline(input_file, line)) {
+ input.push_back(line);
+ }
+ return input;
+}
+
+inline void waitUntil(ViolinInstrument *violin, MonoWav *wavfile, double until)
+{
+ int delta = until*44100.0 - total_samples;
+ if (delta > 0) {
+ short *array = wavfile->request_fill(delta);
+ violin->wait_samples(array, delta);
+ total_samples += delta;
+ } else {
+ if (delta < 0) {
+ printf("ERROR: going back in time!\n");
+ printf(" now: %lf, requested: %lf\n",
+ total_samples/44100.0, until);
+ exit(1);
+ }
+ }
+}
+
+void command_finger(ViolinInstrument *violin, MonoWav *wavfile, string command)
+{
+ double next_time;
+ int which_string;
+ double finger_position;
+ sscanf(command.c_str(), "f\t%lf\t%i\t%lf",
+ &next_time, &which_string, &finger_position);
+ waitUntil(violin, wavfile, next_time);
+ violin->finger(which_string, finger_position);
+}
+
+void command_wait(ViolinInstrument *violin, MonoWav *wavfile, string command)
+{
+ double next_time;
+ sscanf(command.c_str(), "w\t%lf", &next_time);
+ waitUntil(violin, wavfile, next_time);
+}
+
+void command_pluck(ViolinInstrument *violin, MonoWav *wavfile, string command)
+{
+ double next_time;
+ int which_string;
+ double pluck_position;
+ double pluck_force;
+ sscanf(command.c_str(), "p\t%lf\t%i\t%lf\t%lf", &next_time,
+ &which_string, &pluck_position, &pluck_force);
+ waitUntil(violin, wavfile, next_time);
+ violin->pluck(which_string, pluck_position, pluck_force);
+}
+
+void command_bow(ViolinInstrument *violin, MonoWav *wavfile, string command)
+{
+ double next_time;
+ int which_string;
+ double bow_position, force, velocity;
+ sscanf(command.c_str(), "b\t%lf\t%i\t%lf\t%lf\t%lf", &next_time,
+ &which_string, &bow_position, &force, &velocity);
+ waitUntil(violin, wavfile, next_time);
+ violin->bow(which_string, bow_position, force, velocity);
+}
+
+
+void play_file(vector<string> input, MonoWav *wavfile) {
+ ViolinInstrument *violin = new ViolinInstrument();
+ total_samples = 0;
+
+ for (unsigned int i=0; i<input.size(); i++) {
+ switch (input[i][0]) {
+ case '#':
+ // comment line; do nothing
+ break;
+ case 'w':
+ command_wait(violin, wavfile, input[i]);
+ break;
+ case 'f':
+ command_finger(violin, wavfile, input[i]);
+ break;
+ case 'b':
+ command_bow(violin, wavfile, input[i]);
+ break;
+ case 'p':
+ command_pluck(violin, wavfile, input[i]);
+ break;
+ default:
+ printf("Unrecognized command: ");
+ cout<<input[i][0]<<endl;
+
+ }
+ }
+ delete violin;
+}
+
+
+
+int main(int argc, char **argv) {
+ if (argc != 2) {
+ printf("Usage: ./action2wav FILENAME.action\n");
+ } else {
+ vector<string> input = gulp_file(argv[1]);
+
+ string filename = argv[1];
+ size_t suffix_position = filename.find(".actions");
+ if (suffix_position == string::npos) {
+ printf("File should end in .actions\n");
+ exit(2);
+ }
+ filename.replace(suffix_position, 8, ".wav");
+
+ MonoWav *wavfile = new MonoWav(filename.c_str(),10);
+
+ play_file(input, wavfile);
+
+ delete wavfile;
+ }
+}
View
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="306.84766"
+ height="113.375"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.47 r22583"
+ sodipodi:docname="artifastring-logo.svg"
+ inkscape:export-filename="/home/gperciva/artifastring-logo.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.979899"
+ inkscape:cx="183.85768"
+ inkscape:cy="29.479583"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:snap-global="false"
+ showguides="false"
+ inkscape:window-width="935"
+ inkscape:window-height="776"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="0">
+ <inkscape:grid
+ type="xygrid"
+ id="grid2836"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-22.987183)">
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="-2.5"
+ y="51.971558"
+ id="text2816"><tspan
+ sodipodi:role="line"
+ id="tspan2818"
+ x="-2.5"
+ y="51.971558"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"><tspan
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#ff0000;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"
+ id="tspan2850">artif</tspan>icial</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="93.704689"
+ y="91.971558"
+ id="text2820"><tspan
+ sodipodi:role="line"
+ x="93.704689"
+ y="91.971558"
+ id="tspan2838"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#ff0000;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono">fast</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="142.23828"
+ y="128.08093"
+ id="text2828"><tspan
+ sodipodi:role="line"
+ x="142.23828"
+ y="128.08093"
+ id="tspan2832"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"><tspan
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#ff0000;font-family:Liberation Mono;-inkscape-font-specification:Liberation Mono"
+ id="tspan2856">string</tspan>s</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="69.285713"
+ y="18.076468"
+ id="text2846"><tspan
+ sodipodi:role="line"
+ id="tspan2848"
+ x="69.285713"
+ y="18.076468" /></text>
+ </g>
+</svg>
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
@@ -0,0 +1,17 @@
+Recorded by tapping a crappy violin with a dirty teaspoon in the
+anechoic chamber of Glasgow University department of electrical
+engineering.
+
+
+impulse-2048.wav:
+- cut down to 2048 samples
+- last 63 samples were given a Fade-Out in audacity
+
+impulse-512.wav:
+- cut down to 512 samples
+- last 32 samples were given a Fade-Out in audacity
+
+impulse-128.wav:
+- cut down to 128 samples
+- last 8 samples were given a Fade-Out in audacity
+
Oops, something went wrong.

0 comments on commit 2d4861e

Please sign in to comment.