Exemplo n.º 1
0
static GstElement *
get_sink_bin (void)
{
  BtMachine *machine =
      bt_setup_get_machine_by_type (setup, BT_TYPE_SINK_MACHINE);
  GstElement *sink_bin =
      GST_ELEMENT (check_gobject_get_object_property (machine, "machine"));

  g_object_try_unref (machine);

  return sink_bin;
}
Exemplo n.º 2
0
/*
* In this example you can see, how we get a source machine back by its type.
*/
static void
test_bt_setup_machine_type (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtSetup *setup = BT_SETUP (check_gobject_get_object_property (song, "setup"));
  BtMachine *source = BT_MACHINE (bt_source_machine_new (song, "src",
          "buzztrax-test-mono-source", 0, NULL));

  GST_INFO ("-- act --");
  BtMachine *machine =
      bt_setup_get_machine_by_type (setup, BT_TYPE_SOURCE_MACHINE);

  GST_INFO ("-- assert --");
  fail_unless (machine == source, NULL);

  GST_INFO ("-- cleanup --");
  g_object_unref (machine);
  g_object_unref (setup);
  BT_TEST_END;
}
Exemplo n.º 3
0
/* test master volume, using appsink? */
static void
test_bt_sink_bin_master_volume (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  gdouble volume = 1.0 / (gdouble) _i;
  g_object_set (settings, "audiosink", "fakesink", NULL);
  make_new_song ( /*square */ 1);
  BtMachine *machine =
      bt_setup_get_machine_by_type (setup, BT_TYPE_SINK_MACHINE);
  GstElement *sink_bin =
      GST_ELEMENT (check_gobject_get_object_property (machine, "machine"));
  BtParameterGroup *pg = bt_machine_get_global_param_group (machine);
  gst_element_set_state (sink_bin, GST_STATE_READY);
  GstElement *fakesink = get_sink_element ((GstBin *) sink_bin);
  g_object_set (fakesink, "signal-handoffs", TRUE, NULL);
  g_signal_connect (fakesink, "preroll-handoff", (GCallback) handoff_buffer_cb,
      NULL);
  g_signal_connect (fakesink, "handoff", (GCallback) handoff_buffer_cb, NULL);

  GST_INFO ("-- act --");
  g_object_set (sink_bin, "master-volume", volume, NULL);
  bt_parameter_group_set_param_default (pg,
      bt_parameter_group_get_param_index (pg, "master-volume"));
  bt_song_play (song);
  run_main_loop_until_eos ();

  GST_INFO ("-- assert --");
  GST_INFO ("minv=%7.4lf, maxv=%7.4lf", minv, maxv);
  ck_assert_float_eq (maxv, +volume);
  ck_assert_float_eq (minv, -volume);

  GST_INFO ("-- cleanup --");
  bt_song_stop (song);
  gst_object_unref (sink_bin);
  g_object_try_unref (machine);
  BT_TEST_END;
}
Exemplo n.º 4
0
/**
 * bt_edit_application_load_song:
 * @self: the application instance to load a new song in
 * @file_name: the song filename to load
 * @err: where to store the error message in case of an error, or %NULL
 *
 * Loads a new song. If there is a previous song instance it will be freed.
 *
 * Returns: true for success
 */
gboolean
bt_edit_application_load_song (const BtEditApplication * self,
    const char *file_name, GError ** err)
{
  gboolean res = FALSE;
  BtSongIO *loader;
  BtSong *song;

  g_return_val_if_fail (BT_IS_EDIT_APPLICATION (self), FALSE);

  GST_INFO ("song name = %s", file_name);

  if ((loader = bt_song_io_from_file (file_name, err))) {
    BtSetup *setup;
    GList *missing_machines, *missing_waves;

    bt_edit_application_ui_lock (self);
    g_signal_connect (loader, "notify::status",
        G_CALLBACK (on_songio_status_changed), (gpointer) self);

    // create new song and release the previous one
    song = bt_song_new (BT_APPLICATION (self));
    g_object_set ((gpointer) self, "song", NULL, NULL);

#ifdef USE_DEBUG
    // do sanity check that bin is empty
    {
      GstBin *bin;
      g_object_get ((gpointer) self, "bin", &bin, NULL);

      if (GST_BIN_NUMCHILDREN (bin)) {
        GList *node = GST_BIN_CHILDREN (bin);
        GST_WARNING ("bin.num_children=%d has left-overs",
            GST_BIN_NUMCHILDREN (bin));

        while (node) {
          GST_WARNING_OBJECT (node->data, "removing object %"
              G_OBJECT_REF_COUNT_FMT, G_OBJECT_LOG_REF_COUNT (node->data));
          gst_bin_remove (bin, GST_ELEMENT (node->data));
          node = GST_BIN_CHILDREN (bin);
        }
      }
      gst_object_unref (bin);
    }
#endif

    // this is synchronous execution
    // https://github.com/Buzztrax/buzztrax/issues/52
    // if we bump glib from 2.32 -> 2.36 we can use GTask and
    // g_task_run_in_thread()
    if (bt_song_io_load (loader, song, err)) {
      BtMachine *machine;

      // get sink-machine
      g_object_get (song, "setup", &setup, NULL);
      if ((machine =
              bt_setup_get_machine_by_type (setup, BT_TYPE_SINK_MACHINE))) {
        if (bt_machine_enable_input_post_level (machine)) {
          // DEBUG
          //bt_song_write_to_highlevel_dot_file(song);
          // DEBUG
          // set new song
          g_object_set ((gpointer) self, "song", song, NULL);
          res = TRUE;
          GST_INFO ("new song activated");
        } else {
          GST_WARNING ("Can't add input level/gain element in sink machine");
        }
        GST_DEBUG ("unreffing stuff after loading");
        g_object_unref (machine);
      } else {
        GST_WARNING ("Can't look up sink machine");
      }
      g_object_unref (setup);
    } else {
      GST_WARNING ("could not load song \"%s\"", file_name);
    }
    self->priv->unsaved = FALSE;
    g_object_notify (G_OBJECT (self), "unsaved");

    bt_edit_application_ui_unlock (self);

    // get missing element info
    bt_child_proxy_get (song, "setup::missing-machines", &missing_machines,
        "wavetable::missing-waves", &missing_waves, NULL);
    // tell about missing machines and/or missing waves
    if (missing_machines || missing_waves) {
      GtkWidget *dialog;

      if ((dialog =
              GTK_WIDGET (bt_missing_song_elements_dialog_new (missing_machines,
                      missing_waves)))) {
        bt_edit_application_attach_child_window (self, GTK_WINDOW (dialog));
        gtk_widget_show_all (dialog);

        gtk_dialog_run (GTK_DIALOG (dialog));
        gtk_widget_destroy (dialog);
      }
    }
    g_object_unref (song);
    g_object_unref (loader);
  } else {
    GST_WARNING ("Unknown extension \"%s\"", file_name);
  }
  return res;
}