Help - Search - Members - Calendar
Full Version: Script for automatic decoding of mpc
Hydrogenaudio Forums > Lossy Audio Compression > MPC
d-b
I have a lot of mpc:s I want to decode to aiff/wav - where can I find script to do this automatically? I need nothing fancy, I just want

1. Title.mpc

to become

1. Title.aiff

but the mppdec just pipes the decoded mpc to stdout when I

mppdec *mpc /test/

Thanks in advance
dev0
Another problem easily solved by using SOX:

mppdec file.mpc - | sox - file.aiff
xmixahlx
i use a bash script on linux for decoding:

CODE

#!/bin/sh
for file in *mpc
do
nice --adjustment=15 mppdec --wav "$file" .
done


--wav becomes --aiff quite easily smile.gif

...and nice isn't necessary, i just use it so it doesn't interfere with what i'm doing atm

if it is $(file).mpc.wav just rename:
rename 's/mpc.wav/wav/' *


later
goweropolis
Thanks for the bash script X. I just installed the musepack-encoder package the other day. (Why are you using the alpha as opposed to the beta? I assume there's probably not that much difference between the two.) I was trying to encode using the following:
CODE
mppenc --xlevel *.wav
but that didn't seem to work. Adjusting your bash script worked out well for my encoding needs:
CODE
#!/bin/sh
for file in *wav
do
mppenc --xlevel "$file"
done


Do you know how to make a recursive bash script? I am interested in ripping a bunch of CDs to the hard drive (one per subfolder) and I'd like to encode to MPC then replaygain all of them. I am just learning about bash scripting so bear with me. I hoped that X (or someone else) might have some cool scripts to share.
phong
I pity windows users on a daily basis for their lack of a easy-to-use, powerful, general purpose scripting language. Linux an Mac (owing to OS X's BSD heritage) have a a plethora from which to choose. It's gotten to the point where I cannot operate a computer without being able to script things... It is very difficult to suffer away on a Windows box that lacks cygwin.

There are at least two ways to make recursive bash scripts. The most obvious way is to just call itself (any bash script behaves just like any other command). For example, this would encode all wav files recursively in a directory tree (assume the script is named "mppall"):

CODE
#!/bin/bash
for file in *.wav; do
  mppenc --standard --xlevel "$file"
done
for file in *; do
  if [ -d "$file" ]; then
    cd "$file"
    mppall
    cd ..
  fi
done


You can also define functions. Functions act exactly like mini shell scripts that operate within other shell scripts and are called the same way as anything else. If you define a function in your .bashrc or .bash_profile (depending on your system, either may work, or just one...) it will be available in your shell environment and can be used like any other command. They can also call themselves recursively. This is the same script as the one above, except it uses a function and operates on it's command line parameters instead of the current directory.

CODE
#!/bin/bash
function mppdir() {
  for file in "$1"/*.wav; do
     mppenc --standard --xlevel "$file"
  done
  for file in "$1"/*; do
     if [ -d "$file" ]; then
       mppdir "$file"
     fi
  done
}

for param in "$@"; do
  mppdir "$param"
done


It first defines the function, then calls it for every command line parameter. Isn't that just sexy? You could probably do the same thing with "find" but I did it this way to illustrate the scripting technique.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.