Ejemplo n.º 1
0
static void
test_bt_machine_state_solo_resets_others (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *src1 =
      BT_MACHINE (bt_source_machine_new (song, "gen1", "audiotestsrc", 0L,
          NULL));
  BtMachine *src2 =
      BT_MACHINE (bt_source_machine_new (song, "gen2", "audiotestsrc", 0L,
          NULL));
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "sink", NULL));
  bt_wire_new (song, src1, sink, NULL);
  bt_wire_new (song, src2, sink, NULL);

  GST_INFO ("-- act --");
  g_object_set (src1, "state", BT_MACHINE_STATE_SOLO, NULL);
  g_object_set (src2, "state", BT_MACHINE_STATE_SOLO, NULL);

  GST_INFO ("-- assert --");
  ck_assert_gobject_guint_eq (src1, "state", BT_MACHINE_STATE_NORMAL);
  ck_assert_gobject_guint_eq (src2, "state", BT_MACHINE_STATE_SOLO);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 2
0
static void
test_bt_machine_state_bypass_no_sideeffects (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *src =
      BT_MACHINE (bt_source_machine_new (song, "gen", "audiotestsrc", 0L,
          NULL));
  BtMachine *proc =
      BT_MACHINE (bt_processor_machine_new (song, "vol", "volume", 0L, NULL));
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "sink", NULL));
  bt_wire_new (song, src, proc, NULL);
  bt_wire_new (song, proc, sink, NULL);

  GST_INFO ("-- act --");
  g_object_set (proc, "state", BT_MACHINE_STATE_BYPASS, NULL);

  GST_INFO ("-- assert --");
  ck_assert_gobject_guint_eq (src, "state", BT_MACHINE_STATE_NORMAL);
  ck_assert_gobject_guint_eq (proc, "state", BT_MACHINE_STATE_BYPASS);
  ck_assert_gobject_guint_eq (sink, "state", BT_MACHINE_STATE_NORMAL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 3
0
/*
* check if we can disconnect a src machine from a sink while playing.
*/
static void
test_bt_setup_dynamic_rem_src (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtSetup *setup =
      (BtSetup *) check_gobject_get_object_property (song, "setup");
  BtSequence *sequence =
      (BtSequence *) check_gobject_get_object_property (song, "sequence");
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "master", NULL));
  BtMachine *gen1 =
      BT_MACHINE (bt_source_machine_new (song, "gen1", "audiotestsrc", 0L,
          NULL));
  BtMachine *gen2 =
      BT_MACHINE (bt_source_machine_new (song, "gen2", "audiotestsrc", 0L,
          NULL));
  bt_wire_new (song, gen1, sink, NULL);
  BtWire *wire2 = bt_wire_new (song, gen2, sink, NULL);
  GstElement *element1 =
      (GstElement *) check_gobject_get_object_property (gen1, "machine");
  GstElement *element2 =
      (GstElement *) check_gobject_get_object_property (gen2, "machine");

  g_object_set (sequence, "length", 64L, "loop", TRUE, NULL);
  bt_sequence_add_track (sequence, gen1, -1);
  bt_sequence_add_track (sequence, gen2, -1);
  g_object_set (element1, "wave", /* silence */ 4, NULL);
  g_object_set (element2, "wave", /* silence */ 4, NULL);
  bt_machine_set_param_defaults (gen1);
  bt_machine_set_param_defaults (gen2);
  mark_point ();

  /* play the song */
  if (bt_song_play (song)) {
    mark_point ();
    check_run_main_loop_until_playing_or_error (song);
    GST_DEBUG ("song plays");

    /* unlink machines */
    bt_setup_remove_wire (setup, wire2);
    GST_DEBUG ("wire removed");

    g_usleep (G_USEC_PER_SEC / 10);

    /* stop the song */
    bt_song_stop (song);
  } else {
    fail ("playing of song failed");
  }

  GST_INFO ("-- cleanup --");
  g_object_unref (setup);
  g_object_unref (sequence);
  BT_TEST_END;
}
Ejemplo n.º 4
0
static void
bt_cmd_pattern_set_property (GObject * const object, const guint property_id,
    const GValue * const value, GParamSpec * const pspec)
{
  BtCmdPattern *const self = BT_CMD_PATTERN (object);

  return_if_disposed ();
  switch (property_id) {
    case CMD_PATTERN_SONG:
      self->priv->song = BT_SONG (g_value_get_object (value));
      g_object_try_weak_ref (self->priv->song);
      //GST_DEBUG("set the song for pattern: %p",self->priv->song);
      break;
    case CMD_PATTERN_NAME:
      g_free (self->priv->name);
      self->priv->name = g_value_dup_string (value);
      GST_DEBUG ("set the display name for the pattern: '%s'",
          self->priv->name);
      break;
    case CMD_PATTERN_MACHINE:
      self->priv->machine = BT_MACHINE (g_value_get_object (value));
      g_object_try_weak_ref (self->priv->machine);
      break;
    case CMD_PATTERN_COMMAND:
      self->priv->cmd = g_value_get_enum (value);
      GST_DEBUG ("set the cmd for the pattern: %d", self->priv->cmd);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
  }
}
Ejemplo n.º 5
0
static void
test_bt_machine_unbind_parameter_controls (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "id",
          "buzztrax-test-mono-source", 0, NULL));
  GstObject *element =
      (GstObject *) check_gobject_get_object_property (machine, "machine");
  BtParameterGroup *pg = bt_machine_get_global_param_group (machine);
  BtIcControl *control = btic_device_get_control_by_name (device, "abs1");
  g_object_set (element, "g-uint", 10, NULL);
  bt_machine_bind_parameter_control (machine, element, "g-uint", control, pg);
  g_object_set (control, "value", 0, NULL);

  GST_INFO ("-- act --");
  bt_machine_unbind_parameter_controls (machine);
  g_object_set (control, "value", 100, NULL);

  GST_INFO ("-- assert --");
  ck_assert_gobject_guint_eq (element, "g-uint", 0);

  GST_INFO ("-- cleanup --");
  gst_object_unref (element);
  g_object_unref (control);
  BT_TEST_END;
}
Ejemplo n.º 6
0
static void
test_bt_wire_can_link (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *gen =
      BT_MACHINE (bt_source_machine_new (song, "gen", "audiotestsrc", 0L,
          NULL));
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "master", NULL));

  /* act & assert */
  fail_unless (bt_wire_can_link (gen, sink));

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 7
0
static BtValueGroup *
get_mono_value_group (void)
{
  machine =
      BT_MACHINE (bt_source_machine_new (song, "id",
          "buzztrax-test-mono-source", 0, NULL));
  pattern = bt_pattern_new (song, "pattern-name", 4L, machine);
  return bt_pattern_get_global_group (pattern);
}
Ejemplo n.º 8
0
/*
 * activate the input level meter in a connected machine
 */
static void
test_bt_machine_enable_input_level2 (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine1 =
      BT_MACHINE (bt_processor_machine_new (song, "vol1", "volume", 0, NULL));
  BtMachine *machine2 =
      BT_MACHINE (bt_processor_machine_new (song, "vol2", "volume", 0, NULL));
  bt_wire_new (song, machine1, machine2, NULL);

  GST_INFO ("-- act --");
  gboolean res = bt_machine_enable_input_pre_level (machine2);

  GST_INFO ("-- assert --");
  fail_unless (res == TRUE, NULL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 9
0
static void
test_bt_wire_pretty_name (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *src =
      BT_MACHINE (bt_source_machine_new (song, "audiotestsrc", "audiotestsrc",
          0L, NULL));
  BtMachine *proc = BT_MACHINE (bt_processor_machine_new (song, "volume",
          "volume", 0L, NULL));
  BtWire *wire = bt_wire_new (song, src, proc, NULL);

  GST_INFO ("-- act --");

  GST_INFO ("-- assert --");
  ck_assert_gobject_str_eq (wire, "pretty-name", "audiotestsrc -> volume");

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 10
0
static void
test_bt_setup_wire_add_machine_id (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));
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "sink", NULL));

  GST_INFO ("-- act --");
  BtWire *wire = bt_wire_new (song, source, sink, NULL);

  GST_INFO ("-- assert --");
  ck_assert_gobject_eq_and_unref (bt_setup_get_wire_by_src_machine (setup,
          source), wire);

  GST_INFO ("-- cleanup --");
  g_object_unref (setup);
  BT_TEST_END;
}
Ejemplo n.º 11
0
static void
test_bt_wire_new (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *gen =
      BT_MACHINE (bt_source_machine_new (song, "gen", "audiotestsrc", 0L,
          NULL));
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "master", NULL));

  GST_INFO ("-- act --");
  GError *err = NULL;
  BtWire *wire = bt_wire_new (song, gen, sink, &err);

  GST_INFO ("-- assert --");
  fail_unless (wire != NULL, NULL);
  fail_unless (err == NULL, NULL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 12
0
static void
test_bt_machine_state_not_overridden (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtSequence *sequence =
      (BtSequence *) check_gobject_get_object_property (song, "sequence");
  BtSongInfo *song_info =
      BT_SONG_INFO (check_gobject_get_object_property (song, "song-info"));
  BtMachine *src = BT_MACHINE (bt_source_machine_new (song, "gen",
          "simsyn", 0L, NULL));
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "sink", NULL));
  bt_wire_new (song, src, sink, NULL);
  BtCmdPattern *pattern = bt_cmd_pattern_new (song, src, BT_PATTERN_CMD_SOLO);
  GstElement *element =
      (GstElement *) check_gobject_get_object_property (src, "machine");

  /* duration: 0:00:00.480000000 */
  g_object_set (song_info, "bpm", 250L, "tpb", 16L, NULL);
  g_object_set (sequence, "length", 32L, NULL);
  bt_sequence_add_track (sequence, src, -1);
  bt_sequence_set_pattern (sequence, 4, 0, pattern);
  g_object_set (element, "wave", /* silence */ 4, NULL);

  GST_INFO ("-- act --");
  g_object_set (src, "state", BT_MACHINE_STATE_MUTE, NULL);
  bt_machine_update_default_state_value (src);
  bt_song_play (song);
  check_run_main_loop_until_eos_or_error (song);

  GST_INFO ("-- assert --");
  ck_assert_gobject_guint_eq (src, "state", BT_MACHINE_STATE_MUTE);

  GST_INFO ("-- cleanup --");
  gst_object_unref (element);
  g_object_unref (pattern);
  g_object_unref (sequence);
  g_object_unref (song_info);
  BT_TEST_END;
}
Ejemplo n.º 13
0
static void
make_new_song (gint wave)
{
  BtSequence *sequence =
      (BtSequence *) check_gobject_get_object_property (song, "sequence");
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "master", NULL));
  BtMachine *gen =
      BT_MACHINE (bt_source_machine_new (song, "gen", "audiotestsrc", 0L,
          NULL));
  BtParameterGroup *pg = bt_machine_get_global_param_group (gen);
  bt_wire_new (song, gen, sink, NULL);
  BtPattern *pattern = bt_pattern_new (song, "pattern-name", 8L, gen);
  GstElement *element =
      (GstElement *) check_gobject_get_object_property (gen, "machine");
  BtSongInfo *song_info =
      (BtSongInfo *) check_gobject_get_object_property (song, "song-info");
  gulong bpm = check_gobject_get_ulong_property (song_info, "bpm");
  gulong tpb = check_gobject_get_ulong_property (song_info, "tpb");

  // figure a good block size for the current tempo
  gint samples_per_buffer = (44100.0 * 60.0) / (bpm * tpb);

  g_object_set (sequence, "length", 4L, "loop", FALSE, NULL);
  bt_sequence_add_track (sequence, gen, -1);
  bt_sequence_set_pattern (sequence, 0, 0, (BtCmdPattern *) pattern);
  g_object_set (element, "wave", wave, "volume", 1.0, "samplesperbuffer",
      samples_per_buffer, NULL);
  bt_parameter_group_set_param_default (pg,
      bt_parameter_group_get_param_index (pg, "wave"));
  bt_parameter_group_set_param_default (pg,
      bt_parameter_group_get_param_index (pg, "volume"));

  gst_object_unref (element);
  g_object_unref (song_info);
  g_object_unref (pattern);
  g_object_unref (sequence);
  GST_INFO ("  song created");
}
Ejemplo n.º 14
0
static void
test_bt_setup_wire_add_dst_list (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));
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "sink", NULL));
  BtWire *wire = bt_wire_new (song, source, sink, NULL);

  GST_INFO ("-- act --");
  GList *list = bt_setup_get_wires_by_dst_machine (setup, sink);

  GST_INFO ("-- assert --");
  fail_unless (list != NULL, NULL);
  ck_assert_int_eq (g_list_length (list), 1);
  ck_assert_gobject_eq_and_unref (BT_WIRE (g_list_first (list)->data), wire);

  GST_INFO ("-- cleanup --");
  g_list_free (list);
  g_object_unref (setup);
  BT_TEST_END;
}
Ejemplo n.º 15
0
static void
test_bt_wire_persistence (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *src =
      BT_MACHINE (bt_source_machine_new (song, "audiotestsrc", "audiotestsrc",
          0L, NULL));
  BtMachine *proc = BT_MACHINE (bt_processor_machine_new (song, "volume",
          "volume", 0L, NULL));
  BtWire *wire = bt_wire_new (song, src, proc, NULL);

  GST_INFO ("-- act --");
  xmlNodePtr parent = xmlNewNode (NULL, XML_CHAR_PTR ("buzztrax"));
  xmlNodePtr node = bt_persistence_save (BT_PERSISTENCE (wire), parent);

  GST_INFO ("-- assert --");
  fail_unless (node != NULL, NULL);
  ck_assert_str_eq ((gchar *) node->name, "wire");
  fail_unless (node->children != NULL, NULL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 16
0
/*
 * activate the output gain control in an unconnected machine
 */
static void
test_bt_machine_enable_output_gain1 (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine =
      BT_MACHINE (bt_processor_machine_new (song, "vol", "volume", 0, NULL));

  GST_INFO ("-- act --");
  gboolean res = bt_machine_enable_output_gain (machine);

  GST_INFO ("-- assert --");
  fail_unless (res == TRUE, NULL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 17
0
static void
test_bt_machine_pretty_name_with_detail (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *src =
      BT_MACHINE (bt_source_machine_new (song, "gen", "audiotestsrc", 0L,
          NULL));

  GST_INFO ("-- act --");

  GST_INFO ("-- assert --");
  ck_assert_gobject_str_eq (src, "pretty-name", "gen (audiotestsrc)");

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 18
0
/* add pattern */
static void
test_bt_machine_add_pattern (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "gen",
          "buzztrax-test-poly-source", 1L, NULL));

  GST_INFO ("-- act --");
  BtPattern *pattern = bt_pattern_new (song, "pattern-name", 8L, machine);

  GST_INFO ("-- assert --");
  fail_unless (bt_machine_has_patterns (machine), NULL);

  GST_INFO ("-- cleanup --");
  g_object_unref (pattern);
  BT_TEST_END;
}
Ejemplo n.º 19
0
static void
test_bt_cmd_pattern_obj_poly1 (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "gen",
          "buzztrax-test-poly-source", 2L, NULL));

  GST_INFO ("-- act --");
  BtCmdPattern *pattern =
      bt_cmd_pattern_new (song, machine, BT_PATTERN_CMD_MUTE);

  GST_INFO ("-- assert --");
  ck_assert_gobject_guint_eq (pattern, "command", BT_PATTERN_CMD_MUTE);

  GST_INFO ("-- cleanup --");
  g_object_unref (pattern);
  BT_TEST_END;
}
Ejemplo n.º 20
0
static void
test_bt_machine_create (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");

  GST_INFO ("-- act --");
  GError *err = NULL;
  BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "gen",
          element_names[_i], element_voices[_i], &err));

  GST_INFO ("-- assert --");
  fail_unless (machine != NULL, NULL);
  fail_unless (err == NULL, NULL);
  fail_unless (!bt_machine_has_patterns (machine), NULL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Ejemplo n.º 21
0
static void
test_bt_machine_check_voices (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");

  GST_INFO ("-- act --");
  BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "gen",
          "buzztrax-test-poly-source", 2L, NULL));

  GST_INFO ("-- assert --");
  GstChildProxy *element =
      (GstChildProxy *) check_gobject_get_object_property (machine, "machine");
  ck_assert_int_eq (gst_child_proxy_get_children_count (element), 2);
  //ck_assert_gobject_gulong_eq(machine,"voices",2);

  GST_INFO ("-- cleanup --");
  gst_object_unref (element);
  BT_TEST_END;
}
Ejemplo n.º 22
0
static void
test_bt_setup_machine_rem_id (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 --");
  bt_setup_remove_machine (setup, source);

  GST_INFO ("-- assert --");
  ck_assert_gobject_eq_and_unref (bt_setup_get_machine_by_id (setup, "src"),
      NULL);

  GST_INFO ("-- cleanup --");
  g_object_unref (setup);
  BT_TEST_END;
}
Ejemplo n.º 23
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;
}
Ejemplo n.º 24
0
static void
test_bt_machine_list_model_get_machine (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  GtkTreeIter iter;
  BtMachine *machine1 = BT_MACHINE (bt_source_machine_new (song, "gen",
          "buzztrax-test-mono-source", 0, NULL));
  BtMachineListModel *model = bt_machine_list_model_new (setup);
  gtk_tree_model_get_iter_first ((GtkTreeModel *) model, &iter);

  GST_INFO ("-- act --");
  BtMachine *machine2 = bt_machine_list_model_get_object (model, &iter);

  GST_INFO ("-- assert --");
  fail_unless (machine1 == machine2, NULL);

  GST_INFO ("-- cleanup --");
  g_object_unref (model);
  BT_TEST_END;
}
Ejemplo n.º 25
0
static void
test_bt_machine_next_pattern_name (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "gen",
          "buzztrax-test-poly-source", 1L, NULL));
  BtPattern *pattern = bt_pattern_new (song, "00", 8L, machine);

  GST_INFO ("-- act --");
  gchar *pattern_name = bt_machine_get_unique_pattern_name (machine);

  GST_INFO ("-- assert --");
  ck_assert_str_eq (pattern_name, "01");

  GST_INFO ("-- cleanup --");
  g_free (pattern_name);
  g_object_unref (pattern);

  BT_TEST_END;
}
Ejemplo n.º 26
0
static void
test_bt_setup_machine_add_updates_list (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 --");
  GList *list = (GList *) check_gobject_get_ptr_property (setup, "machines");

  GST_INFO ("-- assert --");
  fail_unless (list != NULL, NULL);
  ck_assert_int_eq (g_list_length (list), 1);
  fail_unless ((BtMachine *) list->data == source, NULL);

  GST_INFO ("-- cleanup --");
  g_list_free (list);
  g_object_unref (setup);
  BT_TEST_END;
}
Ejemplo n.º 27
0
/*
 * change voices and verify that voices in machine and patetrn are in sync
 */
static void
test_bt_machine_change_voices (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "gen",
          "buzztrax-test-poly-source", 1L, NULL));
  BtPattern *p1 = bt_pattern_new (song, "pattern-name1", 8L, machine);
  BtPattern *p2 = bt_pattern_new (song, "pattern-name2", 8L, machine);

  GST_INFO ("-- act --");
  g_object_set (machine, "voices", 2, NULL);

  GST_INFO ("-- assert --");
  ck_assert_gobject_gulong_eq (p1, "voices", 2);
  ck_assert_gobject_gulong_eq (p2, "voices", 2);

  GST_INFO ("-- cleanup --");
  g_object_unref (p1);
  g_object_unref (p2);
  BT_TEST_END;
}
Ejemplo n.º 28
0
static void
test_bt_machine_set_defaults (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine = BT_MACHINE (bt_source_machine_new (song, "id",
          "buzztrax-test-mono-source", 0, NULL));
  GstObject *element =
      (GstObject *) check_gobject_get_object_property (machine, "machine");
  GstControlBinding *cb = gst_object_get_control_binding (element, "g-uint");
  g_object_set (element, "g-uint", 10, NULL);

  GST_INFO ("-- act --");
  bt_machine_set_param_defaults (machine);

  GST_INFO ("-- assert --");
  GValue *val = gst_control_binding_get_value (cb, G_GUINT64_CONSTANT (0));
  guint uval = g_value_get_uint (val);
  ck_assert_int_eq (uval, 10);

  GST_INFO ("-- cleanup --");
  gst_object_unref (element);
  BT_TEST_END;
}
Ejemplo n.º 29
0
/**
 * bt_edit_application_new_song:
 * @self: the application instance to create a new song in
 *
 * Creates a new blank song instance. If there is a previous song instance it
 * will be freed.
 *
 * Returns: %TRUE for success
 */
gboolean
bt_edit_application_new_song (const BtEditApplication * self)
{
  gboolean res = FALSE;
  BtSong *song;
  BtSetup *setup;
  BtMachine *machine;
  gchar *id;
  gulong bars;
  GError *err = NULL;

  g_return_val_if_fail (BT_IS_EDIT_APPLICATION (self), FALSE);

  // create new song
  song = bt_song_new (BT_APPLICATION (self));

  bt_child_proxy_get (song, "setup", &setup, "song-info::bars", &bars, NULL);
  // make initial song length 4 timelines
  bt_child_proxy_set (song, "sequence::length", bars * 4, NULL);
  // add audiosink
  id = bt_setup_get_unique_machine_id (setup, "master");
  machine = BT_MACHINE (bt_sink_machine_new (song, id, &err));
  if (err == NULL) {
    GHashTable *properties;

    GST_DEBUG ("sink-machine=%" G_OBJECT_REF_COUNT_FMT,
        G_OBJECT_LOG_REF_COUNT (machine));
    g_object_get (machine, "properties", &properties, NULL);
    if (properties) {
      gchar str[G_ASCII_DTOSTR_BUF_SIZE];
      g_hash_table_insert (properties, g_strdup ("xpos"),
          g_strdup (g_ascii_dtostr (str, G_ASCII_DTOSTR_BUF_SIZE, 0.0)));
      g_hash_table_insert (properties, g_strdup ("ypos"),
          g_strdup (g_ascii_dtostr (str, G_ASCII_DTOSTR_BUF_SIZE, 0.0)));
    }
    if (bt_machine_enable_input_post_level (machine)) {
      GST_DEBUG ("sink-machine=%" G_OBJECT_REF_COUNT_FMT,
          G_OBJECT_LOG_REF_COUNT (machine));
      // set new song in application
      g_object_set ((gpointer) self, "song", song, NULL);
      res = TRUE;
    } else {
      GST_WARNING ("Can't add input level/gain element in sink machine");
    }
    GST_DEBUG ("sink-machine=%" G_OBJECT_REF_COUNT_FMT,
        G_OBJECT_LOG_REF_COUNT (machine));
  } else {
    GST_WARNING ("Can't create sink machine: %s", err->message);
    g_error_free (err);
    gst_object_unref (machine);
  }
  g_free (id);

  self->priv->unsaved = FALSE;
  g_object_notify (G_OBJECT (self), "unsaved");

  // release references
  g_object_unref (setup);
  g_object_unref (song);
  return res;
}