Aide pour un script [résolu]

Post Reply
Message
Author
patrick21
Posts: 43
Joined: Sat 09 Aug 2014, 04:13

Aide pour un script [résolu]

#1 Post by patrick21 »

Bonjour,

j'aurais besoin d'aide pour un script.

J'utilise Soundstretch en ligne de commande pour manipuler des fichiers wav.

Pour un seul fichier, ça va. Par ex pour baisser de 3 demi-tons:

Code: Select all

soundstretch input.wav output.wav -pitch=-3
Mais j'aimerais faire ça pour plusieurs fichiers en même temps. J'aissayé:

Code: Select all

#!/bin/bash
pitch=-3
for f in *.wav; do
    fname=$(basename $f)
    ext="${fname##*.}"
    base="${fname%.*}"
    ./soundstretch $f $base$pitch.$ext -pitch=$pitch
done

Sans succès. Quelqu'un aurait-il une idée. Merci

La page de soundstrecht
https://www.surina.net/soundtouch/soundstretch.html
Last edited by patrick21 on Tue 31 Jul 2018, 09:22, edited 1 time in total.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#2 Post by Argolance »

Bonjour,
Ne manque-t-il pas le chemin complet du dossier contenant les fichiers wav?

Code: Select all

for f in /chemin/vers/dossier/*.wav; do 
Cordialement.

patrick21
Posts: 43
Joined: Sat 09 Aug 2014, 04:13

#3 Post by patrick21 »

merci de ta réponse.

Le script est dans le dossier où sont les fichiers. Mais peut-être que cela ne suffit pas. Je vais essayer.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#4 Post by Argolance »

Code: Select all

for f in ./*.wav; do 
:?:

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#5 Post by Argolance »

Autrement, va dans la rubrique "Programming" de la partie anglophone, tu trouveras sans doute quelqu'un qui se fera un plaisir de te dépanner, ou encore sur le forum Ubuntu, où j'ai pour ma part trouvé pratiquement toutes les réponses à mes "problèmes". :wink:

Cordialement.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: Aide pour un script

#6 Post by MochiMoppel »

patrick21 wrote:

Code: Select all

#!/bin/bash
pitch=-3
for f in *.wav; do
    fname=$(basename $f)
    ext="${fname##*.}"
    base="${fname%.*}"
    ./soundstretch $f $base$pitch.$ext -pitch=$pitch
done

First you need to change to the working directory (= directory of script and wav files)
This should work:

Code: Select all

cd "${0%/*}"
for f in *.wav; do
P.S. I google translated this page. French is all Greek to me :lol:

patrick21
Posts: 43
Joined: Sat 09 Aug 2014, 04:13

#7 Post by patrick21 »

Bonjour,

j'ai trouvé ce qui buggait. En fait, il faut certainement indiquer le chemin du fichier, mais surtout le ./ avant soundstretch n'a pas l'air correct.

J'ai changé le script de:

Code: Select all

#!/bin/bash
pitch=-3
for f in *.wav; do
    fname=$(basename $f)
    ext="${fname##*.}"
    base="${fname%.*}"
    ./soundstretch $f $base$pitch.$ext -pitch=$pitch
done 
vers

Code: Select all

#!/bin/bash
pitch=-3
cd /root/test
for f in *.wav; do
    fname=$(basename $f)
    ext="${fname##*.}"
    base="${fname%.*}"
    soundstretch $f $base$pitch.$ext -pitch=$pitch
done 
et cela a fonctionné. En tout cas, merci beaucoup pour votre aide.

MochiMoppel, I modified the script and added the workin directory (not with your writing, because I did not understand it), and I remove the ./ before soudstrecht wihich seems to be for windows. I dont know if it is properly made, but it works.

Thank you!

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#8 Post by MochiMoppel »

patrick21 wrote:I remove the ./ before soudstrecht wihich seems to be for windows
Bonjour and congratulations!

./ before soundstretch is not only for WIndows. Since you used it in your code I assumed that you did this on purpose. You must use this syntax if the file soundstretch is located in the directory of the script and the *.wav files. If you saved soundstretch into one of the directories where bash searches for executable files, e.g. /usr/bin , then this syntax will not work.

patrick21
Posts: 43
Joined: Sat 09 Aug 2014, 04:13

#9 Post by patrick21 »

Thanks for the explanation. I did not use this syntax really on purpose, I just copied a script. But I understand that, in my case, the ./ was not necessary.

Post Reply