Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear;
- clc;
- close;
- //1. Ouverture du fichier .wav
- [fichier, adresse]=uigetfile('*.wav');// on ouvre une page qui permet de mettre dans une variable fichier, qui peut uniquement etre un .wav
- cd (adresse);
- [chanson, meta]=loadwave(fichier);
- Fe=meta(3);
- //2. Développement d'une banque d'effets
- //SOUS ECHANTILLONAGE//
- function y=sous_ech(x)
- N=abs(round(input('Entrer le facteur de sous echantillonage:')));
- y=chanson(:,1:N:$);
- // playsnd(y,Fe/N);
- endfunction
- // SOUS QUANTIFICATION//
- function y=sous_quant(x)
- p=abs(round(input('Entrer le nombre de bit de quantification:')));
- precision=10/(2^p-1);
- y= round(chanson/precision)*precision;
- // playsnd(y,Fe);
- endfunction
- //FONDU ENTREE//
- function y=fondu_entree(x)
- tps=input('Entre la durée du fondu (en secondes) :');
- N=Fe*tps;
- y=x;
- for k=1:N
- y(:,k)=(k-1)/N*x(:,k);
- end
- // playsnd(y,Fe);
- endfunction
- //FONDU SORTIE//
- function y=fondu_sortie(x)
- y=reverse(fondu_entree(reverse(x)));
- // playsnd(y,Fe);
- endfunction
- //INVERSION
- function y=reverse(x)
- y=x(:,$:-1:1);
- // playsnd(y,Fe);
- endfunction
- //TREMOLO//
- function y=tremolo(x)
- nb_ech=size(x,2);
- ligne=size(x,1);
- Te=1/Fe
- A=input('Veuillez choisir l amplitude de trémolo:');
- f=input('Veuillez choisir la fréquence du trémolo:');
- t=[0:nb_ech-1]*Te;
- trem=A*(1-cos(2*%pi*f*t));
- trem_2=[];
- for k=1:ligne
- trem_2=[trem_2;trem]
- end
- y=x.*trem_2;
- endfunction
- //CHORUS//
- function y=chorus(x)
- tps=input('Rentrez une valeur entre 50 et 200ms')/1000;
- N=round(Fe*tps);
- x_decale=[zeros(size(x,1), N) x];
- y=x+x_decale(:,1:$-N);
- endfunction
- //BRUIT//
- function y=bruit(x)
- taux_bruit=input('Entrez le pourcentage de bruit à ajouter en %');
- A=taux_bruit/100*abs(max(x));
- y=x+A*(rand(size(x, 1), size(x, 2))-rand(size(x, 1));
- endfunction
- //NORMALISATION//
- function y=normalisation(x)
- A=max(abs(max(x)), abs(min(x));
- y=x/A;
- endfunction
- printf('Choisi un effet a appliquer parmi les suivant: \n\n')
- effet=input("1)Sous echantillonage 2)Sous quantification 3)Faire un fade-in 4)Faire une fade-out 5)Inverser la musique 6)Faire un tremolo " )
- select effet
- case 1 then
- y=sous_ech(chanson);
- playsnd(y,Fe/N);
- case 2 then
- y=sous_quant(chanson);
- playsnd(y,Fe);
- case 3 then
- y=fondu_entree(chanson);
- playsnd(y,Fe);
- case 4 then
- y=fondu_sortie(chanson);
- playsnd(y,Fe);
- case 5 then
- y=inversion(chanson);
- playsnd(y,Fe);
- case 6 then
- y=tremolo(chanson);
- playsnd(y,Fe);
- case 7 then
- y=chorus(chanson);
- playsnd(y,Fe);
- case 8 then
- y=bruit(chanson);
- playsnd(y,Fe);
- case 9 then
- y=noramlisation
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement