*/
#include "config.h"
+#include <glib.h>
#include <gst/gst.h>
#include <gtk/gtk.h>
+#include "ui-common.h"
#include "audio.h"
#include "audio-note.h"
static note_pipeline note_play;
static note_pipeline note_record;
static GstBus *bus;
+static gchar *cfile=NULL;
static gboolean
audio_note_record_cb(GtkWidget *widget, gpointer data)
{
-audio_note_record("/tmp/testing.wav");
+const gchar *basedir;
+gchar buffer[128];
+audio_note_ui *ui=(audio_note_ui *)data;
+GDate *gd;
+time_t t;
+struct tm *tmp;
+
+/* XXX: Make this a configuration option */
+#ifdef WITH_DEVICE_770
+basedir="/media/mmc1/MapperAudioNotes";
+if (g_mkdir_with_parents(basedir, 0775)==-1) {
+ MACRO_BANNER_SHOW_INFO(_window, _("Failed to create directory for sound files!"));
+ return TRUE;
+}
+#else
+basedir=g_get_home_dir();
+#endif
+
+t=time(NULL);
+tmp=localtime(&t);
+if (tmp == NULL) {
+ MACRO_BANNER_SHOW_INFO(_window, _("Failed to get timestamp for file!"));
+ return TRUE;
+}
+strftime(buffer, sizeof(buffer), "%Y-%m-%d-%H:%M:%S", tmp);
+
+if (cfile)
+ g_free(cfile);
+
+cfile=g_strdup_printf("%s/an-%s.wav", basedir, buffer);
+
+audio_note_record(cfile);
+
+MACRO_BANNER_SHOW_INFO(_window, _("Recording..."));
+
return TRUE;
}
static gboolean
audio_note_play_cb(GtkWidget *widget, gpointer data)
{
-audio_note_play("/tmp/testing.wav");
+audio_note_ui *ui=(audio_note_ui *)data;
+
+audio_note_play(cfile);
+MACRO_BANNER_SHOW_INFO(_window, _("Playing..."));
return TRUE;
}
static gboolean
audio_note_stop_cb(GtkWidget *widget, gpointer data)
{
-audio_note_stop();
+if (audio_note_stop()==TRUE)
+ MACRO_BANNER_SHOW_INFO(_window, _("Stopped..."));
return TRUE;
}
np->src=gst_element_factory_make(AUDIO_SRC, "source");
np->filter=gst_element_factory_make("wavenc", "filter");
np->sink=gst_element_factory_make("filesink", "sink");
-#if 0
- /* No idea wasting space with some hifi format */
- np->caps=gst_element_factory_make("capsfilter", "caps");
+
+ gst_bin_add_many(GST_BIN(np->pipeline), np->src, np->filter, np->sink, NULL);
+
+#ifndef WITH_DEVICE_770
+ /* Don't waste space with some hifi format */
np->srccaps=gst_caps_new_simple ("audio/x-raw-int",
"depth", G_TYPE_INT, 16,
"signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 16,
- "rate", G_TYPE_INT, 8000,
+ "width", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, 11025,
"channels", G_TYPE_INT, 1,
NULL);
+ if (!gst_element_link_filtered(np->src, np->filter, np->srccaps))
+ g_printerr("Failed to set caps for source\n");
+ else
+ gst_element_link(np->src, np->filter);
+ gst_caps_unref(np->srccaps);
+#else
+ gst_element_link(np->src, np->filter);
#endif
- gst_bin_add_many(GST_BIN(np->pipeline), np->src, np->filter, np->sink, NULL);
- if (!gst_element_link_many(np->src, np->filter, np->sink, NULL))
- g_printerr("Failed to link record pipeline\n");
+ gst_element_link(np->filter, np->sink);
+
} else {
g_debug("GST: Creating playback pipeline");
np->src=gst_element_factory_make("filesrc", "source");