<LI><A HREF="#plugins">plugins</A> - documentation for the various input plugins.</LI>
<LI><A HREF="#libflac">libFLAC API</A> - for developers who want to add FLAC support to their programs.</LI>
<LI><A HREF="#bugs">bugs</A> - known bugs.</LI>
+ <LI><A HREF="#monkey">How to add FLAC support to the Monkey's Audio GUI</A></LI>
</UL>
</P>
<P>
</TABLE>
+<TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="5" BORDER="0">
+<TR><TD>
+ <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
+ <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#D3D4C5">
+ <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+ <A NAME="monkey"><B><FONT SIZE="+2">monkey</FONT></B>
+ </FONT></TD></TR>
+ </TABLE>
+ <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
+ <TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#EEEED4">
+ <TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+ <P>
+ Monkey's Audio comes with a nice GUI that many people are familiar with. It supports some external encoders, but not FLAC. However, the FLAC Windows distribution comes with a utility that allows you to replace one the of the supported lossless external codecs with FLAC. Here's how:
+ <UL>
+ <LI>Copy <B><TT>flac.exe</TT></B> and <B><TT>flac_ren.exe</TT></B> to the <B><TT>External/</TT></B> directory of the Monkey's Audio installation.</LI>
+ <LI>
+ Choose a supported encoder to replace:
+ <UL>
+ <LI>Shorten - copy <B><TT>flac_mac.exe</TT></B> on top of <B><TT>External/shortn32.exe</TT></B></LI>
+ <LI>WavPack - copy <B><TT>flac_mac.exe</TT></B> on top of both <B><TT>External/wavpack.exe</TT></B> and <B><TT>External/wvunpack.exe</TT></B></LI>
+ <LI>RKAU - copy <B><TT>flac_mac.exe</TT></B> on top of <B><TT>External/rkau.exe</TT></B></LI>
+ </UL>
+ If you choose WavPack you will also be able to use the WavPack Configuration menu to add flac options.
+ </LI>
+ <LI>Now you can encode FLAC files as if you were using the replaced encoder. The renamed <B><TT>flac_mac.exe</TT></B> utility will call <B><TT>flac.exe</TT></B> and afterwards, <B><TT>flac_ren.exe</TT></B> will rename the resulting file to have the .flac extension.</LI>
+ </UL>
+ </P>
+ </FONT>
+ </TD></TR>
+ </TABLE>
+ <TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR BGCOLOR="#000000"><TD><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR></TABLE>
+</TD></TR>
+</TABLE>
+
+
</CENTER>
<P> Copyright (c) 2000,2001 Josh Coalson</P>
--- /dev/null
+/* flac_mac - wedge utility to add FLAC support to Monkey's Audio\r
+ * Copyright (C) 2000,2001 Josh Coalson\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
+ */\r
+\r
+/*\r
+ * This program can be used to allow FLAC to masquerade as one of the other\r
+ * supported lossless codecs in Monkey's Audio. See the documentation for\r
+ * how to do this.\r
+ */\r
+\r
+#include<stdio.h>\r
+#include<stdlib.h>\r
+#include<string.h>\r
+#include<wtypes.h>\r
+#include<process.h>\r
+#include<winbase.h>\r
+\r
+static int execit(char *prog, char *args);\r
+static int forkit(char *prog, char *args);\r
+\r
+int main(int argc, char *argv[])\r
+{\r
+ int flac_return_val = 0, opt_arg = 1, from_arg = -1, to_arg = -1, flac_level = 5, i;\r
+ char prog[MAX_PATH], cmdline[MAX_PATH*2], from[MAX_PATH], to[MAX_PATH], macdir[MAX_PATH], options[256], *p;\r
+ enum { WAVPACK, RKAU, SHORTEN } codec;\r
+\r
+ /* get the directory where MAC external codecs reside */\r
+ if(0 != (p = strrchr(argv[0],'\\'))) {\r
+ strcpy(macdir, argv[0]);\r
+ *(strrchr(macdir,'\\')+1) = '\0';\r
+ }\r
+ else {\r
+ strcpy(macdir, "");\r
+ }\r
+\r
+ /* determine which codec we were called as and parse the options */\r
+ if(p == 0)\r
+ p = argv[0];\r
+ else\r
+ p++;\r
+ if(0 == strnicmp(p, "short", 5)) {\r
+ codec = SHORTEN;\r
+ }\r
+ else if(0 == strnicmp(p, "rkau", 4)) {\r
+ codec = RKAU;\r
+ if(argv[1][0] == '-' && argv[1][1] == 'l') {\r
+ opt_arg = 2;\r
+ switch(argv[1][2]) {\r
+ case '1': flac_level = 1; break;\r
+ case '2': flac_level = 5; break;\r
+ case '3': flac_level = 8; break;\r
+ }\r
+ }\r
+ }\r
+ else if(0 == strnicmp(p, "wavpack", 7)) {\r
+ codec = WAVPACK;\r
+ if(argv[1][0] == '-') {\r
+ opt_arg = 2;\r
+ switch(argv[1][1]) {\r
+ case 'f': flac_level = 1; break;\r
+ case 'h': flac_level = 8; break;\r
+ default: opt_arg = 1;\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ return -5;\r
+ }\r
+\r
+ /* figure out which arguments are the source and destination files */\r
+ for(i = 1; i < argc; i++)\r
+ if(argv[i][0] != '-') {\r
+ from_arg = i++;\r
+ break;\r
+ }\r
+ for( ; i < argc; i++)\r
+ if(argv[i][0] != '-') {\r
+ to_arg = i++;\r
+ break;\r
+ }\r
+ if(to_arg < 0)\r
+ return -4;\r
+\r
+ /* build the command to call flac with */\r
+ sprintf(prog, "%sflac.exe", macdir);\r
+ sprintf(options, "-%d", flac_level);\r
+ for(i = opt_arg; i < argc; i++)\r
+ if(argv[i][0] == '-') {\r
+ strcat(options, " ");\r
+ strcat(options, argv[i]);\r
+ }\r
+ sprintf(cmdline, "\"%s\" %s -o \"%s\" \"%s\"", prog, options, argv[to_arg], argv[from_arg]);\r
+\r
+ flac_return_val = execit(prog, cmdline);\r
+\r
+ /*\r
+ * Now that flac has finished, we need to fork a process that will rename\r
+ * the resulting file with the correct extension once MAC has moved it to\r
+ * it's final resting place.\r
+ */\r
+ if(0 == flac_return_val) {\r
+ /* get the destination directory, if any */\r
+ if(0 != (p = strchr(argv[to_arg],'\\'))) {\r
+ strcpy(from, argv[to_arg]);\r
+ *(strrchr(from,'\\')+1) = '\0';\r
+ }\r
+ else {\r
+ strcpy(from, "");\r
+ }\r
+\r
+ /* for the full 'from' and 'to' paths for the renamer process */\r
+ p = strrchr(argv[from_arg],'\\');\r
+ strcat(from, p? p+1 : argv[from_arg]);\r
+ strcpy(to, from);\r
+ if(0 == strchr(from,'.'))\r
+ return -3;\r
+ switch(codec) {\r
+ case SHORTEN: strcpy(strrchr(from,'.'), ".shn"); break;\r
+ case WAVPACK: strcpy(strrchr(from,'.'), ".wv"); break;\r
+ case RKAU: strcpy(strrchr(from,'.'), ".rka"); break;\r
+ }\r
+ strcpy(strrchr(to,'.'), ".flac");\r
+\r
+ sprintf(prog, "%sflac_ren.exe", macdir);\r
+ sprintf(cmdline, "\"%s\" \"%s\" \"%s\"", prog, from, to);\r
+\r
+ flac_return_val = forkit(prog, cmdline);\r
+ }\r
+\r
+ return flac_return_val;\r
+}\r
+\r
+int execit(char *prog, char *args)\r
+{\r
+ BOOL ok;\r
+ STARTUPINFO startup_info;\r
+ PROCESS_INFORMATION proc_info;\r
+\r
+ GetStartupInfo(&startup_info);\r
+\r
+ ok = CreateProcess(\r
+ prog,\r
+ args,\r
+ 0, /*process security attributes*/\r
+ 0, /*thread security attributes*/\r
+ FALSE,\r
+ 0, /*dwCreationFlags*/\r
+ 0, /*environment*/\r
+ 0, /*lpCurrentDirectory*/\r
+ &startup_info,\r
+ &proc_info\r
+ );\r
+ if(ok) {\r
+ DWORD dw;\r
+ dw = WaitForSingleObject(proc_info.hProcess, INFINITE);\r
+ ok = (dw != 0xFFFFFFFF);\r
+ CloseHandle(proc_info.hThread);\r
+ CloseHandle(proc_info.hProcess);\r
+ }\r
+\r
+ return ok? 0 : -1;\r
+}\r
+\r
+int forkit(char *prog, char *args)\r
+{\r
+ BOOL ok;\r
+ STARTUPINFO startup_info;\r
+ PROCESS_INFORMATION proc_info;\r
+\r
+ GetStartupInfo(&startup_info);\r
+\r
+ ok = CreateProcess(\r
+ prog,\r
+ args,\r
+ 0, /*process security attributes*/\r
+ 0, /*thread security attributes*/\r
+ FALSE,\r
+ DETACHED_PROCESS, /*dwCreationFlags*/\r
+ 0, /*environment*/\r
+ 0, /*lpCurrentDirectory*/\r
+ &startup_info,\r
+ &proc_info\r
+ );\r
+ if(ok) {\r
+ CloseHandle(proc_info.hThread);\r
+ CloseHandle(proc_info.hProcess);\r
+ }\r
+\r
+ return ok? 0 : -2;\r
+}\r