/* vim: set sts=2 sw=2 et: */
/* Tuner
* Copyright (C) 2006 Josep Torra <j.torra@telefonica.net>
+ * 2008-2009 Jari Tenhunen <jari.tenhunen@iki.fi>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include "config.h"
#endif
-#define TUNER_VERSION "0.4"
-
#ifdef HILDON
#include <hildon/hildon-defines.h>
#include <hildon/hildon-program.h>
#include <libosso.h>
#define OSSO_PACKAGE "tuner-tool"
-#define OSSO_VERSION TUNER_VERSION
+#define OSSO_VERSION VERSION
#endif /* ifdef HILDON */
#define between(x,a,b) (((x)>=(a)) && ((x)<=(b)))
#define MAGIC (1.059463094359f) /* 2^(1/2) */
+#define CENT (1.0005777895f) /* 1/100th of a half-tone */
+#define LOG_CENT (0.00057762265046662109f) /* ln (CENT) */
extern gboolean plugin_pitch_init (GstPlugin * plugin);
extern gboolean plugin_tonesrc_init (GstPlugin * plugin);
-#define NUM_LEDS (66)
+#define NUM_LEDS (50)
#define NUM_WKEYS (15) /* # of white keys in the piano keyboard */
#define WKEY_WIDTH (45)
}
}
+/* translate the interval (ratio of two freqs) into cents */
+gfloat
+interval2cent (gfloat freq, gfloat note)
+{
+ //return (gfloat) (log (freq / note) / log (CENT));
+ return (gfloat) (log (freq / note) / LOG_CENT);
+}
+
/* update frequency info */
static void
update_frequency (AppData * appdata, gfloat frequency)
gtk_label_set_text (GTK_LABEL (appdata->currentFrequency), buffer);
g_free (buffer);
- draw_leds (appdata, (gint) roundf (min_diff));
+ /* make leds display the difference in steps of two cents */
+ diff = interval2cent (frequency, equal_tempered_scale[j].frequency);
+ draw_leds (appdata, (gint) roundf (diff / 2.0));
}
/* receive spectral data from element message */
return FALSE;
}
+#ifdef FAKE_FREQUENCY
static gboolean
fake_frequency (gpointer user_data)
{
return TRUE;
}
+#endif
#ifdef MAEMO
static void
GtkWidget *label;
GtkWidget *dialog;
- dialog = gtk_dialog_new_with_buttons("About tuner", main_win,
+ dialog = gtk_dialog_new_with_buttons("About Tuner", main_win,
GTK_DIALOG_MODAL |
GTK_DIALOG_DESTROY_WITH_PARENT |
GTK_DIALOG_NO_SEPARATOR,
vbox = gtk_vbox_new (FALSE, HILDON_MARGIN_DEFAULT);
gtk_container_set_border_width (GTK_CONTAINER (vbox), HILDON_MARGIN_DEFAULT);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
- label = gtk_label_new ("Tuner Tool is developed by Josep Torra and Jari Tenhunen.\n"
+ label = gtk_label_new ("Version " VERSION
+ "\nTuner Tool is developed by Josep Torra and Jari Tenhunen.\n"
"http://n770galaxy.blogspot.com/\n");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5);
gtk_init (&argc, &argv);
app = HILDON_PROGRAM (hildon_program_get_instance ());
- g_set_application_name ("Tuner Tool");
+ g_set_application_name ("Tuner");
appdata->app = app;
if (appdata->display_keepalive)
display_keepalive (appdata);
+ draw_leds (appdata, 0);
+
set_pipeline_states (appdata, GST_STATE_PLAYING);
- //g_timeout_add (2000, (GSourceFunc) fake_frequency, appdata);
+#ifdef FAKE_FREQUENCY
+ g_timeout_add (2000, (GSourceFunc) fake_frequency, appdata);
+#endif
gtk_main ();