Example #1
0
static void
bt_wavelevel_constructed (GObject * object)
{
  BtWavelevel *self = BT_WAVELEVEL (object);

  if (G_OBJECT_CLASS (bt_wavelevel_parent_class)->constructed)
    G_OBJECT_CLASS (bt_wavelevel_parent_class)->constructed (object);

  g_return_if_fail (BT_IS_SONG (self->priv->song));
  g_return_if_fail (BT_IS_WAVE (self->priv->wave));

  // add the wavelevel to the wave
  bt_wave_add_wavelevel (self->priv->wave, self);
}
Example #2
0
/**
 * bt_wave_add_wavelevel:
 * @self: the wavetable to add the new wavelevel to
 * @wavelevel: the new wavelevel instance
 *
 * Add the supplied wavelevel to the wave. This is automatically done by
 * #bt_wavelevel_new().
 *
 * Returns: %TRUE for success, %FALSE otheriwse
 */
gboolean
bt_wave_add_wavelevel (const BtWave * const self,
    const BtWavelevel * const wavelevel)
{
  gboolean ret = FALSE;

  g_assert (BT_IS_WAVE (self));
  g_assert (BT_IS_WAVELEVEL (wavelevel));

  if (!g_list_find (self->priv->wavelevels, wavelevel)) {
    ret = TRUE;
    self->priv->wavelevels =
        g_list_append (self->priv->wavelevels,
        g_object_ref ((gpointer) wavelevel));
    //g_signal_emit((gpointer)self,signals[WAVELEVEL_ADDED_EVENT], 0, wavelevel);
  } else {
    GST_WARNING ("trying to add wavelevel again");
  }
  return ret;
}
Example #3
0
/**
 * bt_wavetable_remove_wave:
 * @self: the wavetable to remove the wave from
 * @wave: the wave instance
 *
 * Remove the supplied wave from the wavetable.
 *
 * Returns: %TRUE for success, %FALSE otheriwse
 */
gboolean
bt_wavetable_remove_wave (const BtWavetable * const self,
    const BtWave * const wave)
{
  gboolean ret = FALSE;

  g_assert (BT_IS_WAVETABLE (self));
  g_assert (BT_IS_WAVE (wave));

  if (g_list_find (self->priv->waves, wave)) {
    gulong index;

    g_object_get ((gpointer) wave, "index", &index, NULL);
    update_wave_index_enum (index, g_strdup ("---"));

    self->priv->waves = g_list_remove (self->priv->waves, wave);
    g_signal_emit ((gpointer) self, signals[WAVE_REMOVED_EVENT], 0, wave);
    g_object_unref ((gpointer) wave);
    ret = TRUE;
  } else {
    GST_WARNING ("trying to remove wave that is not in the list");
  }
  return ret;
}
Example #4
0
/**
 * bt_wavetable_add_wave:
 * @self: the wavetable to add the wave to
 * @wave: the new wave instance
 *
 * Add the supplied wave to the wavetable. This is automatically done by
 * #bt_wave_new().
 *
 * Returns: %TRUE for success, %FALSE otheriwse
 */
gboolean
bt_wavetable_add_wave (const BtWavetable * const self,
    const BtWave * const wave)
{
  gboolean ret = FALSE;

  g_assert (BT_IS_WAVETABLE (self));
  g_assert (BT_IS_WAVE (wave));

  if (!g_list_find (self->priv->waves, wave)) {
    gulong index;
    gchar *name;
    BtWave *other_wave;

    // check if there is already a wave with this id ad remove if so
    g_object_get ((gpointer) wave, "index", &index, "name", &name, NULL);
    if ((other_wave = bt_wavetable_get_wave_by_index (self, index))) {
      GST_DEBUG ("replacing old wave with same id");
      self->priv->waves = g_list_remove (self->priv->waves, other_wave);
      //g_signal_emit((gpointer)self,signals[WAVE_REMOVED_EVENT], 0, wave);
      /* TODO(ensonic): if song::is-playing==TRUE add this to a  self->priv->old_waves
       * and wait for song::is-playing==FALSE and free then */
      g_object_unref (other_wave);
    }

    self->priv->waves =
        g_list_append (self->priv->waves, g_object_ref ((gpointer) wave));
    g_signal_emit ((gpointer) self, signals[WAVE_ADDED_EVENT], 0, wave);

    update_wave_index_enum (index, name);
    ret = TRUE;
  } else {
    GST_WARNING ("trying to add wave again");
  }
  return ret;
}