[specimen] PATCH: save master volume
Juuso Alasuutari
iuso at sourcemage.org
Fri Aug 31 14:05:07 CDT 2007
Here's a patch for saving and loading the master volume with the bank. It adds
a child node called "master" to the XML data, which in turn contains a node
called "volume" for storing the value. (It might come in handy to save other
master settings later on, which is why I didn't implement a single node
called master_volume.)
This patch doesn't interact with the GUI, so for this to be usable the master
section needs to be refreshed after loading a patch. When the patch is loaded
the master volume is adjusted accordingly, but the slider stays as-is. I hope
someone who knows GTK+2 can help implement the refreshing, I myself have no
clue whatsoever how to do it.
BEGIN PATCH------------------------------------------------------------
--- src/beef.c~ 2007-08-31 21:34:46.000000000 +0300
+++ src/beef.c 2007-08-31 21:34:53.000000000 +0300
@@ -5,6 +5,7 @@
#include <glib.h>
#include "specimen.h"
#include "patch.h"
+#include "mixer.h"
int beef_write (char *name)
{
@@ -19,6 +20,7 @@
int i, j, count;
xmlDocPtr doc;
xmlNodePtr rootnode;
+ xmlNodePtr xmlmaster;
xmlNodePtr xmlpatch;
#define NR_OF_PPT 5
@@ -40,6 +42,12 @@
rootnode = xmlNewDocNode (doc, NULL, (const xmlChar *) "beef", NULL);
xmlDocSetRootElement (doc, rootnode);
+ xmlmaster = xmlNewTextChild (rootnode, NULL, (const xmlChar *) "master",
+ NULL);
+ sprintf (tmp, "%f", mixer_get_volume ());
+ xmlNewTextChild (xmlmaster, NULL, (const xmlChar *) "volume",
+ (const xmlChar *) tmp);
+
/* walk the walk */
count = patch_dump (&id);
for (i = 0; i < count; i++)
@@ -338,7 +346,7 @@
{
xmlDocPtr doc;
xmlNodePtr rootnode;
- xmlNodePtr xmlpatch;
+ xmlNodePtr childnode;
xmlNodePtr cur;
xmlChar *key;
int id;
@@ -369,16 +377,32 @@
patch_destroy_all ( );
- for (xmlpatch = rootnode->xmlChildrenNode; xmlpatch != NULL;
- xmlpatch = xmlpatch->next)
+ for (childnode = rootnode->xmlChildrenNode; childnode != NULL;
+ childnode = childnode->next)
{
key = NULL;
- if (!xmlStrcmp (xmlpatch->name, (const xmlChar *) "patch"))
+ if (!xmlStrcmp (childnode->name, (const xmlChar *) "master"))
+ {
+ for (cur = childnode->xmlChildrenNode; cur != NULL;
+ cur = cur->next)
+ {
+ if (!xmlStrcmp (cur->name, (const xmlChar *) "volume"))
+ {
+ key =
+ xmlNodeListGetString (doc, cur->xmlChildrenNode,
+ 1);
+ mixer_set_volume (atof ((const char *) key));
+ }
+ }
+ }
+
+ key = NULL;
+ if (!xmlStrcmp (childnode->name, (const xmlChar *) "patch"))
{
id = patch_create ("Loading...");
- for (cur = xmlpatch->xmlChildrenNode; cur != NULL;
+ for (cur = childnode->xmlChildrenNode; cur != NULL;
cur = cur->next)
{
if (!xmlStrcmp (cur->name, (const xmlChar *) "name"))
END PATCH--------------------------------------------------------------
--
Juuso Alasuutari
[[ Source Mage GNU/Linux ]]
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Specimen
mailing list