+float htonf (float v)
+{
+ float result;
+ char * fin = (char*)&v;
+ char * fout = (char*)&result;
+ fout[0] = fin[3];
+ fout[1] = fin[2];
+ fout[2] = fin[1];
+ fout[3] = fin[0];
+ return result;
+}
+
+#if 0
+int fst_load_state (FST * fst, char * filename)
+{
+ FILE * f = fopen (filename, "rb");
+ if (f) {
+ char testMagic[sizeof (magic)];
+ fread (&testMagic, sizeof (magic), 1, f);
+ if (strcmp (testMagic, magic)) {
+ printf ("File corrupt\n");
+ return FALSE;
+ }
+
+ char productString[64];
+ char vendorString[64];
+ char effectName[64];
+ char testString[64];
+ unsigned length;
+ int success;
+
+ fread (&length, sizeof (unsigned), 1, f);
+ length = htonl (length);
+ fread (productString, length, 1, f);
+ productString[length] = 0;
+ printf ("Product string: %s\n", productString);
+
+ success = fst_call_dispatcher( fst, effGetProductString, 0, 0, testString, 0 );
+ if (success == 1) {
+ if (strcmp (testString, productString) != 0) {
+ printf ("Product string mismatch! Plugin has: %s\n", testString);
+ fclose (f);
+ return FALSE;
+ }
+ } else if (length != 0) {
+ printf ("Product string mismatch! Plugin has none.\n", testString);
+ fclose (f);
+ return FALSE;
+ }
+
+ fread (&length, sizeof (unsigned), 1, f);
+ length = htonl (length);
+ fread (effectName, length, 1, f);
+ effectName[length] = 0;
+ printf ("Effect name: %s\n", effectName);
+
+ success = fst_call_dispatcher( fst, effGetEffectName, 0, 0, testString, 0 );
+ if (success == 1) {
+ if (strcmp (testString, effectName) != 0) {
+ printf ("Effect name mismatch! Plugin has: %s\n", testString);
+ fclose (f);
+ return FALSE;
+ }
+ } else if (length != 0) {
+ printf ("Effect name mismatch! Plugin has none.\n", testString);
+ fclose (f);
+ return FALSE;
+ }
+
+ fread (&length, sizeof (unsigned), 1, f);
+ length = htonl (length);
+ fread (vendorString, length, 1, f);
+ vendorString[length] = 0;
+ printf ("Vendor string: %s\n", vendorString);
+
+ success = fst_call_dispatcher( fst, effGetVendorString, 0, 0, testString, 0 );
+ if (success == 1) {
+ if (strcmp (testString, vendorString) != 0) {
+ printf ("Vendor string mismatch! Plugin has: %s\n", testString);
+ fclose (f);
+ return FALSE;
+ }
+ } else if (length != 0) {
+ printf ("Vendor string mismatch! Plugin has none.\n", testString);
+ fclose (f);
+ return FALSE;
+ }
+
+ int numParam;
+ unsigned i;
+ fread (&numParam, sizeof (int), 1, f);
+ numParam = htonl (numParam);
+ for (i = 0; i < numParam; ++i) {
+ float val;
+ fread (&val, sizeof (float), 1, f);
+ val = htonf (val);
+
+ pthread_mutex_lock( &fst->lock );
+ fst->plugin->setParameter( fst->plugin, i, val );
+ pthread_mutex_unlock( &fst->lock );
+ }
+
+ int bytelen;
+ fread (&bytelen, sizeof (int), 1, f);
+ bytelen = htonl (bytelen);
+ if (bytelen) {
+ char * buf = malloc (bytelen);
+ fread (buf, bytelen, 1, f);
+
+ fst_call_dispatcher( fst, 24, 0, bytelen, buf, 0 );
+ free (buf);
+ }
+ } else {
+ printf ("Could not open state file\n");
+ return FALSE;
+ }
+ return TRUE;
+
+}
+#endif
+