From 96a5d88839a6ccb920555b8166fbaaeefcb1f378 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Sat, 3 Nov 2001 00:16:03 +0000 Subject: [PATCH] add monkeys audio utils --- doc/documentation.html | 36 ++++ src/monkeys_audio_utilities/Makefile.am | 18 ++ src/monkeys_audio_utilities/flac_mac/Makefile.am | 20 +++ src/monkeys_audio_utilities/flac_mac/Makefile.vc | 18 ++ src/monkeys_audio_utilities/flac_mac/main.c | 204 +++++++++++++++++++++++ src/monkeys_audio_utilities/flac_ren/Makefile.am | 20 +++ src/monkeys_audio_utilities/flac_ren/Makefile.vc | 18 ++ src/monkeys_audio_utilities/flac_ren/main.c | 35 ++++ 8 files changed, 369 insertions(+) create mode 100644 src/monkeys_audio_utilities/Makefile.am create mode 100644 src/monkeys_audio_utilities/flac_mac/Makefile.am create mode 100644 src/monkeys_audio_utilities/flac_mac/Makefile.vc create mode 100644 src/monkeys_audio_utilities/flac_mac/main.c create mode 100644 src/monkeys_audio_utilities/flac_ren/Makefile.am create mode 100644 src/monkeys_audio_utilities/flac_ren/Makefile.vc create mode 100644 src/monkeys_audio_utilities/flac_ren/main.c diff --git a/doc/documentation.html b/doc/documentation.html index 6bca4a2..c32476d 100644 --- a/doc/documentation.html +++ b/doc/documentation.html @@ -85,6 +85,7 @@
  • plugins - documentation for the various input plugins.
  • libFLAC API - for developers who want to add FLAC support to their programs.
  • bugs - known bugs.
  • +
  • How to add FLAC support to the Monkey's Audio GUI
  • @@ -945,6 +946,41 @@ + + +
    +
    + + +
    + monkey +
    +
    + + +
    +

    + 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: +

      +
    • Copy flac.exe and flac_ren.exe to the External/ directory of the Monkey's Audio installation.
    • +
    • + Choose a supported encoder to replace: +
        +
      • Shorten - copy flac_mac.exe on top of External/shortn32.exe
      • +
      • WavPack - copy flac_mac.exe on top of both External/wavpack.exe and External/wvunpack.exe
      • +
      • RKAU - copy flac_mac.exe on top of External/rkau.exe
      • +
      + If you choose WavPack you will also be able to use the WavPack Configuration menu to add flac options. +
    • +
    • Now you can encode FLAC files as if you were using the replaced encoder. The renamed flac_mac.exe utility will call flac.exe and afterwards, flac_ren.exe will rename the resulting file to have the .flac extension.
    • +
    +

    +
    +
    +
    +
    + +

     Copyright (c) 2000,2001 Josh Coalson

    diff --git a/src/monkeys_audio_utilities/Makefile.am b/src/monkeys_audio_utilities/Makefile.am new file mode 100644 index 0000000..ea5f779 --- /dev/null +++ b/src/monkeys_audio_utilities/Makefile.am @@ -0,0 +1,18 @@ +# FLAC - Free Lossless Audio Codec +# Copyright (C) 2001 Josh Coalson +# +# This program is part of FLAC; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +SUBDIRS = flacmac flacren diff --git a/src/monkeys_audio_utilities/flac_mac/Makefile.am b/src/monkeys_audio_utilities/flac_mac/Makefile.am new file mode 100644 index 0000000..b442d8a --- /dev/null +++ b/src/monkeys_audio_utilities/flac_mac/Makefile.am @@ -0,0 +1,20 @@ +# flac_mac - wedge utility to add FLAC support to Monkey's Audio +# Copyright (C) 2001 Josh Coalson +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +EXTRA_DIST = \ + Makefile.vc \ + main.c diff --git a/src/monkeys_audio_utilities/flac_mac/Makefile.vc b/src/monkeys_audio_utilities/flac_mac/Makefile.vc new file mode 100644 index 0000000..42b28f8 --- /dev/null +++ b/src/monkeys_audio_utilities/flac_mac/Makefile.vc @@ -0,0 +1,18 @@ +!include + +.c.obj: + $(cc) $(cdebug) $(cflags) -DSTRICT -YX /O2 -DNODEBUG $< + +C_FILES= \ + main.c + +OBJS= $(C_FILES:.c=.obj) + +all: flac_mac.exe + +flac_mac.exe: $(OBJS) + link.exe $(OBJS) -out:$*.exe + +clean: + -del *.obj *.pch + -del flac_mac.exe diff --git a/src/monkeys_audio_utilities/flac_mac/main.c b/src/monkeys_audio_utilities/flac_mac/main.c new file mode 100644 index 0000000..579f326 --- /dev/null +++ b/src/monkeys_audio_utilities/flac_mac/main.c @@ -0,0 +1,204 @@ +/* flac_mac - wedge utility to add FLAC support to Monkey's Audio + * Copyright (C) 2000,2001 Josh Coalson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* + * This program can be used to allow FLAC to masquerade as one of the other + * supported lossless codecs in Monkey's Audio. See the documentation for + * how to do this. + */ + +#include +#include +#include +#include +#include +#include + +static int execit(char *prog, char *args); +static int forkit(char *prog, char *args); + +int main(int argc, char *argv[]) +{ + int flac_return_val = 0, opt_arg = 1, from_arg = -1, to_arg = -1, flac_level = 5, i; + char prog[MAX_PATH], cmdline[MAX_PATH*2], from[MAX_PATH], to[MAX_PATH], macdir[MAX_PATH], options[256], *p; + enum { WAVPACK, RKAU, SHORTEN } codec; + + /* get the directory where MAC external codecs reside */ + if(0 != (p = strrchr(argv[0],'\\'))) { + strcpy(macdir, argv[0]); + *(strrchr(macdir,'\\')+1) = '\0'; + } + else { + strcpy(macdir, ""); + } + + /* determine which codec we were called as and parse the options */ + if(p == 0) + p = argv[0]; + else + p++; + if(0 == strnicmp(p, "short", 5)) { + codec = SHORTEN; + } + else if(0 == strnicmp(p, "rkau", 4)) { + codec = RKAU; + if(argv[1][0] == '-' && argv[1][1] == 'l') { + opt_arg = 2; + switch(argv[1][2]) { + case '1': flac_level = 1; break; + case '2': flac_level = 5; break; + case '3': flac_level = 8; break; + } + } + } + else if(0 == strnicmp(p, "wavpack", 7)) { + codec = WAVPACK; + if(argv[1][0] == '-') { + opt_arg = 2; + switch(argv[1][1]) { + case 'f': flac_level = 1; break; + case 'h': flac_level = 8; break; + default: opt_arg = 1; + } + } + } + else { + return -5; + } + + /* figure out which arguments are the source and destination files */ + for(i = 1; i < argc; i++) + if(argv[i][0] != '-') { + from_arg = i++; + break; + } + for( ; i < argc; i++) + if(argv[i][0] != '-') { + to_arg = i++; + break; + } + if(to_arg < 0) + return -4; + + /* build the command to call flac with */ + sprintf(prog, "%sflac.exe", macdir); + sprintf(options, "-%d", flac_level); + for(i = opt_arg; i < argc; i++) + if(argv[i][0] == '-') { + strcat(options, " "); + strcat(options, argv[i]); + } + sprintf(cmdline, "\"%s\" %s -o \"%s\" \"%s\"", prog, options, argv[to_arg], argv[from_arg]); + + flac_return_val = execit(prog, cmdline); + + /* + * Now that flac has finished, we need to fork a process that will rename + * the resulting file with the correct extension once MAC has moved it to + * it's final resting place. + */ + if(0 == flac_return_val) { + /* get the destination directory, if any */ + if(0 != (p = strchr(argv[to_arg],'\\'))) { + strcpy(from, argv[to_arg]); + *(strrchr(from,'\\')+1) = '\0'; + } + else { + strcpy(from, ""); + } + + /* for the full 'from' and 'to' paths for the renamer process */ + p = strrchr(argv[from_arg],'\\'); + strcat(from, p? p+1 : argv[from_arg]); + strcpy(to, from); + if(0 == strchr(from,'.')) + return -3; + switch(codec) { + case SHORTEN: strcpy(strrchr(from,'.'), ".shn"); break; + case WAVPACK: strcpy(strrchr(from,'.'), ".wv"); break; + case RKAU: strcpy(strrchr(from,'.'), ".rka"); break; + } + strcpy(strrchr(to,'.'), ".flac"); + + sprintf(prog, "%sflac_ren.exe", macdir); + sprintf(cmdline, "\"%s\" \"%s\" \"%s\"", prog, from, to); + + flac_return_val = forkit(prog, cmdline); + } + + return flac_return_val; +} + +int execit(char *prog, char *args) +{ + BOOL ok; + STARTUPINFO startup_info; + PROCESS_INFORMATION proc_info; + + GetStartupInfo(&startup_info); + + ok = CreateProcess( + prog, + args, + 0, /*process security attributes*/ + 0, /*thread security attributes*/ + FALSE, + 0, /*dwCreationFlags*/ + 0, /*environment*/ + 0, /*lpCurrentDirectory*/ + &startup_info, + &proc_info + ); + if(ok) { + DWORD dw; + dw = WaitForSingleObject(proc_info.hProcess, INFINITE); + ok = (dw != 0xFFFFFFFF); + CloseHandle(proc_info.hThread); + CloseHandle(proc_info.hProcess); + } + + return ok? 0 : -1; +} + +int forkit(char *prog, char *args) +{ + BOOL ok; + STARTUPINFO startup_info; + PROCESS_INFORMATION proc_info; + + GetStartupInfo(&startup_info); + + ok = CreateProcess( + prog, + args, + 0, /*process security attributes*/ + 0, /*thread security attributes*/ + FALSE, + DETACHED_PROCESS, /*dwCreationFlags*/ + 0, /*environment*/ + 0, /*lpCurrentDirectory*/ + &startup_info, + &proc_info + ); + if(ok) { + CloseHandle(proc_info.hThread); + CloseHandle(proc_info.hProcess); + } + + return ok? 0 : -2; +} diff --git a/src/monkeys_audio_utilities/flac_ren/Makefile.am b/src/monkeys_audio_utilities/flac_ren/Makefile.am new file mode 100644 index 0000000..e6e8254 --- /dev/null +++ b/src/monkeys_audio_utilities/flac_ren/Makefile.am @@ -0,0 +1,20 @@ +# flac_ren - renamer part of utility to add FLAC support to Monkey's Audio +# Copyright (C) 2001 Josh Coalson +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +EXTRA_DIST = \ + Makefile.vc \ + main.c diff --git a/src/monkeys_audio_utilities/flac_ren/Makefile.vc b/src/monkeys_audio_utilities/flac_ren/Makefile.vc new file mode 100644 index 0000000..137a49f --- /dev/null +++ b/src/monkeys_audio_utilities/flac_ren/Makefile.vc @@ -0,0 +1,18 @@ +!include + +.c.obj: + $(cc) $(cdebug) $(cflags) /I "..\..\include" /I ".\include" -DSTRICT -YX /O2 -DNODEBUG $< + +C_FILES= \ + main.c + +OBJS= $(C_FILES:.c=.obj) + +all: flac_ren.exe + +flac_ren.exe: $(OBJS) + link.exe $(OBJS) -out:$*.exe + +clean: + -del *.obj *.pch + -del flac_ren.exe diff --git a/src/monkeys_audio_utilities/flac_ren/main.c b/src/monkeys_audio_utilities/flac_ren/main.c new file mode 100644 index 0000000..fbbad40 --- /dev/null +++ b/src/monkeys_audio_utilities/flac_ren/main.c @@ -0,0 +1,35 @@ +/* flac_ren - renamer part of utility to add FLAC support to Monkey's Audio + * Copyright (C) 2000,2001 Josh Coalson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + struct stat s; + + /* wait till the 'from' file has reached its final destination */ + do { + Sleep(2000); + } while(stat(argv[1], &s) < 0); + + /* now rename it */ + return rename(argv[1], argv[2]); +} -- 2.7.4