Exemple #1
0
static xmlNodePtr
bt_song_info_persistence_save (const BtPersistence * const persistence,
    xmlNodePtr const parent_node)
{
  const BtSongInfo *const self = BT_SONG_INFO (persistence);
  xmlNodePtr node = NULL;

  GST_DEBUG ("PERSISTENCE::song-info");

  if ((node = xmlNewChild (parent_node, NULL, XML_CHAR_PTR ("meta"), NULL))) {
    if (!strcmp (self->priv->name, DEFAULT_SONG_NAME)) {
      gchar *file_path = NULL, *file_name, *ext;

      bt_child_proxy_get (self->priv->song, "song-io::file-name", &file_path,
          NULL);
      if (file_path) {
        file_name = g_path_get_basename (file_path);
        if ((ext = strrchr (file_name, '.'))) {
          *ext = '\0';
        }
        GST_INFO ("using '%s' instead of default title", file_name);
        g_object_set ((gpointer) self, "name", file_name, NULL);
        g_free (file_name);
        g_free (file_path);
      }
    }

    if (self->priv->info) {
      xmlNewChild (node, NULL, XML_CHAR_PTR ("info"),
          XML_CHAR_PTR (self->priv->info));
    }
    if (self->priv->name) {
      xmlNewChild (node, NULL, XML_CHAR_PTR ("name"),
          XML_CHAR_PTR (self->priv->name));
    }
    if (self->priv->genre) {
      xmlNewChild (node, NULL, XML_CHAR_PTR ("genre"),
          XML_CHAR_PTR (self->priv->genre));
    }
    if (self->priv->author) {
      xmlNewChild (node, NULL, XML_CHAR_PTR ("author"),
          XML_CHAR_PTR (self->priv->author));
    }
    if (self->priv->create_dts) {
      xmlNewChild (node, NULL, XML_CHAR_PTR ("create-dts"),
          XML_CHAR_PTR (self->priv->create_dts));
    }
    if (self->priv->change_dts) {
      xmlNewChild (node, NULL, XML_CHAR_PTR ("change-dts"),
          XML_CHAR_PTR (self->priv->change_dts));
    }
    xmlNewChild (node, NULL, XML_CHAR_PTR ("bpm"),
        XML_CHAR_PTR (bt_str_format_ulong (self->priv->beats_per_minute)));
    xmlNewChild (node, NULL, XML_CHAR_PTR ("tpb"),
        XML_CHAR_PTR (bt_str_format_ulong (self->priv->ticks_per_beat)));
    xmlNewChild (node, NULL, XML_CHAR_PTR ("bars"),
        XML_CHAR_PTR (bt_str_format_ulong (self->priv->bars)));
  }
  return node;
}
static xmlNodePtr
bt_processor_machine_persistence_save (const BtPersistence * const persistence,
    xmlNodePtr const parent_node)
{
  const BtProcessorMachine *const self = BT_PROCESSOR_MACHINE (persistence);
  const BtPersistenceInterface *const parent_iface =
      g_type_interface_peek_parent (BT_PERSISTENCE_GET_INTERFACE (persistence));
  xmlNodePtr node = NULL;
  gchar *const plugin_name;
  gulong voices;

  GST_DEBUG ("PERSISTENCE::processor-machine");

  // save parent class stuff
  if ((node = parent_iface->save (persistence, parent_node))) {
    xmlNewProp (node, XML_CHAR_PTR ("type"), XML_CHAR_PTR ("processor"));

    g_object_get ((gpointer) self, "plugin-name", &plugin_name, "voices",
        &voices, NULL);
    xmlNewProp (node, XML_CHAR_PTR ("plugin-name"), XML_CHAR_PTR (plugin_name));
    xmlNewProp (node, XML_CHAR_PTR ("voices"),
        XML_CHAR_PTR (bt_str_format_ulong (voices)));
    g_free (plugin_name);
  }
  return node;
}
Exemple #3
0
static xmlNodePtr
bt_wave_persistence_save (const BtPersistence * const persistence,
    const xmlNodePtr const parent_node)
{
  const BtWave *const self = BT_WAVE (persistence);
  xmlNodePtr node = NULL;
  xmlNodePtr child_node;

  GST_DEBUG ("PERSISTENCE::wave");

  if ((node = xmlNewChild (parent_node, NULL, XML_CHAR_PTR ("wave"), NULL))) {
    BtSongIONative *song_io;

    // we need to have a uri
    if (!self->priv->uri)
      self->priv->uri = g_strdup (self->priv->name);

    xmlNewProp (node, XML_CHAR_PTR ("index"),
        XML_CHAR_PTR (bt_str_format_ulong (self->priv->index)));
    xmlNewProp (node, XML_CHAR_PTR ("name"), XML_CHAR_PTR (self->priv->name));
    xmlNewProp (node, XML_CHAR_PTR ("uri"), XML_CHAR_PTR (self->priv->uri));
    xmlNewProp (node, XML_CHAR_PTR ("volume"),
        XML_CHAR_PTR (bt_str_format_double (self->priv->volume)));
    xmlNewProp (node, XML_CHAR_PTR ("loop-mode"),
        XML_CHAR_PTR (bt_str_format_enum (BT_TYPE_WAVE_LOOP_MODE,
                self->priv->loop_mode)));

    // check if we need to save external data
    g_object_get (self->priv->song, "song-io", &song_io, NULL);
    if (song_io) {
      if (BT_IS_SONG_IO_NATIVE_BZT (song_io)) {
        gchar *uri = NULL;

        if (self->priv->ext_fd == -1) {
          // need to write in memory data to a wav
          bt_wave_save_to_fd (self);
        }
        uri = g_strdup_printf ("fd://%d", self->priv->ext_fd);
        bt_wave_save_from_fd (self, song_io, uri);
        g_free (uri);
      }
      g_object_unref (song_io);
    }
    // save wavelevels
    if ((child_node =
            xmlNewChild (node, NULL, XML_CHAR_PTR ("wavelevels"), NULL))) {
      bt_persistence_save_list (self->priv->wavelevels, child_node);
    }
  }
  return node;
}
Exemple #4
0
static xmlNodePtr
bt_wavelevel_persistence_save (const BtPersistence * const persistence,
    xmlNodePtr const parent_node)
{
  const BtWavelevel *const self = BT_WAVELEVEL (persistence);
  xmlNodePtr node = NULL;

  GST_DEBUG ("PERSISTENCE::wavelevel");

  if ((node =
          xmlNewChild (parent_node, NULL, XML_CHAR_PTR ("wavelevel"), NULL))) {
    // only serialize customizable properties
    xmlNewProp (node, XML_CHAR_PTR ("root-note"),
        XML_CHAR_PTR (bt_str_format_uchar (self->priv->root_note)));
    xmlNewProp (node, XML_CHAR_PTR ("rate"),
        XML_CHAR_PTR (bt_str_format_ulong (self->priv->rate)));
    xmlNewProp (node, XML_CHAR_PTR ("loop-start"),
        XML_CHAR_PTR (bt_str_format_long (self->priv->loop_start)));
    xmlNewProp (node, XML_CHAR_PTR ("loop-end"),
        XML_CHAR_PTR (bt_str_format_long (self->priv->loop_end)));
  }
  return node;
}