From 43b1189c1353b091eb4d7bfe4ac8dbed165799a6 Mon Sep 17 00:00:00 2001
From: Martin Karlsson <letter2martin@gmail.com>
Date: Thu, 24 Sep 2015 14:17:47 +0200
Subject: [PATCH] hej

---
 get_audio.m   | 37 +++++++++++++++++++++++++++++++++++++
 startup_rob.m |  8 ++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 get_audio.m
 create mode 100644 startup_rob.m

diff --git a/get_audio.m b/get_audio.m
new file mode 100644
index 0000000..0bf8bb1
--- /dev/null
+++ b/get_audio.m
@@ -0,0 +1,37 @@
+function signal = get_audio()
+
+global bass;
+
+
+persistent lastLastIndex;
+persistent lastIndex;
+persistent fs;
+persistent p;
+
+
+if isempty(fs)
+    p = bass.Audio();
+    fs = p.Audio.sampleRate;
+    lastLastIndex = 0;
+    lastIndex = 0;
+    
+end
+p = bass.Audio();
+
+
+
+pause(0.1)
+lastIndex = p.Audio.lastFrameIndex;
+diffIndex = lastIndex - lastLastIndex;
+tempLeft = cell2mat(p.Audio.left);
+tempLeft = tempLeft(max(end-diffIndex+1,1):end);
+
+tempRight = cell2mat(p.Audio.right);
+tempRight = tempRight(max(end-diffIndex+1,1):end);
+
+
+lastLastIndex = lastIndex;
+
+signal = [tempLeft; tempRight];
+
+end
\ No newline at end of file
diff --git a/startup_rob.m b/startup_rob.m
new file mode 100644
index 0000000..4744efa
--- /dev/null
+++ b/startup_rob.m
@@ -0,0 +1,8 @@
+
+global client
+global bass
+
+addpath(genpath('~/openrobots/lib/matlab/'));
+client = genomix.client('turtlebot1-wifi:8080');
+bass = client.load('bass');
+bass.Acquire('-a',24414,2048,80);
\ No newline at end of file
-- 
GitLab