Convert wav to mp3 with a right click option

Audio editors, music players, video players, burning software, etc.
Message
Author
User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#16 Post by RSH »

Hello, don570!

Tonight i have discovered your Rightclick-Audioconversiontool. It was a nice Surprise to me, to find my translation added to this Tool. I am lucky about that, and so i have downloaded it and installed it in my Puppy Studio rebuild No. 37.

I works fine, and: I LIKE IT!

Nice Work and the Code is truly education to me. I am just a beginner in writing GUIS for some Tools. May be you are interested in my GUI for the Bristol Software Synthesizers, they can be found here: http://www.mediafire.com/file/6pr21567d ... 86-GUI.pet. Also the Bristol Synthesizers: http://www.mediafire.com/file/xm7q4jb99 ... 1_i386.pet

To let you understand, how much i like this Tool, i'd started to make a translation for the folder-convert-1.1.pet. So, here is the folder_convert-NLS-de-1.1.pet, with only the german translation within.

Please add this one to your NLS-File - if you like to do so.

Wish you well,

RSH
Attachments
folder_convert-NLS-de-1.1.pet
(1.09 KiB) Downloaded 430 times

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#17 Post by don570 »

Thanks for the translation.

folder_convert was an experiment. I don't have training in
programming so I wrote it in a strange way
that professionals would laugh at, I'm sure.

..but it seems to work, so I posted it along with conversion_audio
which ought to be in every Puppy.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#18 Post by RSH »

Hello don570,

i like your .pet stuff and even the code. I've been a programmer for years and years back there, from 1990 to 2007. But, in PASCAL and doing it using another OS: the TOS, AtariST Series. Later using the TOSBOX on Windows ME, wich gives me 14 MB RAM and a whole lot of speed. Sometimes i have to make some scrolling-functions in my own programs a little less faster manually by programming-code.

Now let's take a look at my Problem. It has to do with the code from your rightclick audio stuff. While i am reading your code, i am trying to translate it to PASCAL.
I hope it will help me a little, to understand this script-programming-code (has it got a name, like PASCAL, C++ or JAVA).

Let me explain: if i'm writing "extension", this means to me the (almost) three characters after the dot. (.pet for example)

Code: Select all

z=`echo "$1" | sed "s/\/$//"`
t="${z%.*}"
z=`echo "$1" | sed "s/\/$//"` gives me the full path- and filename after the mouseclick, right?
After "t="${z%.*}"[/code]" there's only the full path- and filename without the extension, right?

Or am i totally wrong?

So, i want this code to return to me

1. the full path- and filename WITH extension
2. the full path- and filename WITHOUT extension
3. only the filename

2. and 3. maybe can be done by me, using string-functions like the PASCAL-functions (delete, insert concat etc). L18L shows me some equivalents.

In PASCAL we call them STRINGS and i need these strings in a form or way to do something with them like copy, delete and insert parts of them or other strings, declared by myself.

Can you help me? Any Idea?

What is

Code: Select all

"$1"
, ist it the right mouse-button?

What is echo doing here?

Code: Select all

sed "s/\/$//
What is t doing here?

Code: Select all

t="${z%.*}"
RSH
Last edited by RSH on Wed 09 Nov 2011, 14:28, edited 1 time in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#19 Post by don570 »

You seem to know more about programming
than me. It's the blind leading the blind. :lol:

Here's a tip that has been invaluable for me.

If a script isn't working, then insert the following:

Code: Select all

gxmessage bingo
This shows me if I have reached a certain part in a
script. This is especially valuable in loops.

As well I find often that there is a need to
find out the variables value so I insert the
following line

Code: Select all

 gxmessage   APP_LIST= "$APP_LIST"
to find the value of a variable named APP_List.

I often write small scripts in /root to check out
my theories on how a script will act.

There's a list of free info here -->

http://murga-linux.com/puppy/viewtopic.php?t=71288

I personally use this for any Bash scripting I've done--->
http://www.murga-linux.com/puppy/viewtopic.php?t=40422
What is
Code:
"$1"
It look like a simple inputing of a variable.
If you had three inputs, they would be automatically
named $1 $2 $3 by bash shell.

What is echo doing here?
Code:
sed "s/\/$//
Programmers like to stick an echo line by itself
to show a blank line in the terminal.
Is that what is confusing you?
I should have taken it out if I left it in.
What is t doing here?
Code:
t="${z%.*}"
That looks like some clumsy coding by me.
I should have given descriptive variable names
rather than letters. It's a bad habit I've gotten into.
You should avoid doing it. A gxmessage line should find out
what it is. Note that I used quotes to preserve the whitespace!!!



If you read the script found here
http://www.murga-linux.com/puppy/viewtopic.php?t=71927
there's use of 'dirname' and 'basename' which I've avoided
doing, mainly because of my lack of knowledge,
but also because they don't appear to work in functions
and child processes.

If you want to know about a line of script I've written you
should give me a line number --> It's a menu option in Geany.


___________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

loop example

#20 Post by don570 »

A script to understand loops that I have found.
The 'shift' command is used to switch to a new argument in
the list.

Code: Select all

#!/bin/bash
echo "Argument value is: $1"

while [ "$*" != "" ]
do
echo "Argument value is: $1"
shift
done
Here is terminal output for different inputs

# ./script a b c d
Argument value is: a
Argument value is: a
Argument value is: b
Argument value is: c
Argument value is: d


The double quotation mark does protect whitespace

# ./script "a b" "c d"
Argument value is: a b
Argument value is: a b
Argument value is: c d

_______________________________________
Last edited by don570 on Wed 02 Nov 2011, 00:07, edited 1 time in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#21 Post by don570 »

another loop example with for statement

Code: Select all

#!/bin/bash
echo "Argument value is: $1"

for item in "$@"
do
echo "Argument value is: $item"
done


terminal output is


# ./script 1 2 4 6
Argument value is: 1
Argument value is: 1
Argument value is: 2
Argument value is: 4
Argument value is: 6

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#22 Post by RSH »

Hello don570,

thank you for your help.

After help and hints from big_bass, emil, L18L, PANZERKOPF, rhadon and you, i was able to create the tool, i wanted to create. It works fine. Now i have to put all these things together (saving to hd) and study it. There's a lot of documentation i've found.

The Tool is created as ROX-App, like your Audiotools. The Code is fully commended in german and english. So, i think, you should take a look inside, because if have found out something interesting about:

Code: Select all

t="${z%.*}"
The pet is here:

http://murga-linux.com/puppy/viewtopic. ... 2&start=15

RSH

Edit:
You seem to know more about programming
than me. It's the blind leading the blind. Laughing
Let me tell you something to this. From Time to Time i've been working as a teacher for playing drums. In the private sector and even on schools. So, everytime i've teached anybody, i've learned something at the same time. And for sure, i've learned from your posts as well.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#23 Post by don570 »

I've been studying loops and here's some things
I've learned. I show the script ,
then the output in the terminal.

Here's a quick way of making a list for a loop
to use each word as an argument

Code: Select all

#!/bin/bash

LIST='apple orange pear plum'
for item in $LIST
do
echo "Argument value is: $item"
done
# ./script
Argument value is: apple
Argument value is: orange
Argument value is: pear
Argument value is: plum

Here is the usual way programmers make a list

Code: Select all

#!/bin/bash

LIST='apple
orange
pear
plum'
for item in $LIST
do
echo "Argument value is: $item"
done
# ./script
Argument value is: apple
Argument value is: orange
Argument value is: pear
Argument value is: plum

Double quotation marks are useless as this example
shows...

Code: Select all

#!/bin/bash

LIST=$(echo "ap ple" orange pear plum)
for item in $LIST
do
echo "Argument value is: $item"
done
 
# ./script
Argument value is: ap
Argument value is: ple
Argument value is: orange
Argument value is: pear
Argument value is: plum


Now I change the IFS (Internal Field Separator) to a comma
and the white space is protected

Code: Select all

#!/bin/bash
IFS=,
LIST='ap ple,orange,pear,plum'
for item in $LIST
do
echo "Argument value is: $item"
done
# ./script
Argument value is: ap ple
Argument value is: orange
Argument value is: pear
Argument value is: plum

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

loop example

#24 Post by don570 »

The following example will loop three times
even though there are 4 arguments

Code: Select all

#!/bin/bash
 
x=1
while [ $x -le 3 ]
do
echo “argument is ....$1″
shift
x=`expr $x + 1`
done
# ./Script "ap ple" orange pear plum
“argument is ....ap ple″
“argument is ....orange″
“argument is ....pear″
Last edited by don570 on Wed 09 Nov 2011, 20:26, edited 2 times in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

new version folder_convert 1.2

#25 Post by don570 »

new version folder_convert 1.2

folder_convert has been fixed to show foreign languages properly.

I dumped the old yaf-splash and now use xdialog


______________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

dejan script

#26 Post by don570 »

Here's a script based on dejan's work.
It allows sed command to work on text that has
whitespace .

Code: Select all

#!/bin/sh
FIND="/ap ple/" 
ADD="/root/" 
echo "/ap ple/spot" |  sed  's:^'"$FIND"':'"$ADD"':' 

The terminal output is


# ./Script
/root/spot


_________________________________________________

Here's a script I wrote to
study positional characters i.e number of inputs --> $#
and to study exit status ---> $?

Code: Select all

#!/bin/bash
echo number of positional characters = $#

until [ -z "$1" ]  # Until all parameters used up . . .
do
echo -n "$1 "
shift
done
echo               # Extra line feed.
echo "$?"          # Determine exit status
if [ -z "$0" ] ; then
echo 
else
echo "$?"
echo "$0"
echo "$?"
fi
exit 0

# ./script a b c
number of positional characters = 3
a b c
0
1
./script
0

_______________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#27 Post by don570 »

Here's a script I found to do simple calculations

Code: Select all

#!/bin/bash
# Simple linux bash calculator 
echo "Enter input:" 
read userinput
echo "Result with 2 digits after decimal point:"
echo "scale=2; ${userinput}" | bc 
echo "Result with 10 digits after decimal point:"
echo "scale=10; ${userinput}" | bc 
echo "Result as rounded integer:"
echo $userinput | bc 
...and the terminal output.
# ./script
Enter input:
2+2
Result with 2 digits after decimal point:
4
Result with 10 digits after decimal point:
4
Result as rounded integer:
4
# ./script
Enter input:
2*8
Result with 2 digits after decimal point:
16
Result with 10 digits after decimal point:
16
Result as rounded integer:
16
# ./script
Enter input:
8/4
Result with 2 digits after decimal point:
2.00
Result with 10 digits after decimal point:
2.0000000000
Result as rounded integer:
2

____________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#28 Post by don570 »

Here's a script I found that does renaming(recursively)
of filenames that have whitespace .

Code: Select all

#!/bin/sh

# This bash script will locate and replace spaces
# in the filenames
DIR="."
# Controlling a loop with bash read command by redirecting STDOUT as
# a STDIN to while loop
# find will not truncate filenames containing spaces
find $DIR -type f | while read file; do
# using POSIX class [:space:] to find space in the filename
if [[ "$file" = *[[:space:]]* ]]; then
# substitute space with "_" character and consequently rename the file
mv "$file" `echo $file | tr ' ' '_'`
fi;
# end of while loop
done 
_____________________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#29 Post by don570 »

French German Spanish Finnish Italian Portugese Dutch
languages now supported

More languages are now supported by conversion_audio
thanks to

Béèm
ferro10n

Instructions to help in conversion effort are here
http://www.murga-linux.com/puppy/viewtopic.php?t=72856

_________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#30 Post by don570 »

Here I tested a new way of inputing variable values
using curly brackets.
Also there is a line in the script to
experiment with the test command ---> [
which is the square bracket. The output is zero
because 5 does not equal 9. The terminal output shows
this outcome.

Code: Select all

#!/bin/sh

FILENAME=$1
EXTENSION=$2
echo $@
[ 5 != 9 ]
echo $?
aplay /root/puppy-reference/audio/${FILENAME}${EXTENSION}
exit 0
Here's the terminal output. Note that there is two inputs
2barks and the extension .wav

Code: Select all

# ./script 2barks .wav
2barks .wav
0
Playing WAVE '/root/puppy-reference/audio/2barks.wav' 
: Signed 16 bit Little Endian, Rate 8000 Hz, Mono

________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#31 Post by don570 »

new version of conversion audio - version 1.5

Two improvements

1) I estimate the conversion time for the user,
however this probably won't be accurate if you have a slow machine

2) I pop a window up to show the conversion so it won't be
such a mystery!


Note: the foreign translations had to be changed as well.
______________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

new version 1.7

#32 Post by don570 »

new version 1.7

opens and converts more audio formats

such as flac and wma

Conversion time is approximate. I give the time needed
assuming the user has a fast machine.

____________________________________________

rmcellig
Posts: 965
Joined: Sat 19 Nov 2011, 15:18
Location: Ottawa Ontario Canada
Contact:

#33 Post by rmcellig »

don570

You mention that pmusic can convert multiple wav files to mp3. How do you go about doing this using pmusic?

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#34 Post by don570 »

It's shinobar's ffconvert that will convert an entire folder

and gnac does as well (but it requires gstreamer I believe,
That's why Jemimah uses it in Saluki)


I wrote a script too

folder_convert-1.2.pet

________________________________________________

rmcellig
Posts: 965
Joined: Sat 19 Nov 2011, 15:18
Location: Ottawa Ontario Canada
Contact:

#35 Post by rmcellig »

I used ffconvert to convert a folder of wav files but I don't think ffconvert can do sub folders as well. Maybe I'm wrong?

Post Reply