Advertisement
Guest User

Untitled

a guest
Jun 15th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 3.05 KB | None | 0 0
  1. clear;
  2. clc;
  3. close;
  4.  
  5. //1. Ouverture du fichier .wav
  6. [fichier, adresse]=uigetfile('*.wav');// on ouvre une page qui permet de mettre dans une variable fichier, qui peut uniquement etre un .wav
  7. cd (adresse);
  8. [chanson, meta]=loadwave(fichier);
  9. Fe=meta(3);
  10.  
  11. //2. Développement d'une banque d'effets
  12.  
  13.  
  14.   //SOUS ECHANTILLONAGE//
  15.   function y=sous_ech(x)
  16.       N=abs(round(input('Entrer le facteur de sous echantillonage:')));
  17.       y=chanson(:,1:N:$);
  18.      // playsnd(y,Fe/N);
  19.   endfunction
  20.  
  21.   // SOUS QUANTIFICATION//
  22.   function y=sous_quant(x)
  23.        p=abs(round(input('Entrer le nombre de bit de quantification:')));
  24.         precision=10/(2^p-1);
  25.     y= round(chanson/precision)*precision;
  26.    // playsnd(y,Fe);
  27.   endfunction
  28.  
  29.   //FONDU ENTREE//
  30.   function y=fondu_entree(x)
  31.       tps=input('Entre la durée du fondu (en secondes) :');
  32.       N=Fe*tps;
  33.       y=x;
  34.       for k=1:N
  35.           y(:,k)=(k-1)/N*x(:,k);
  36.       end
  37.      // playsnd(y,Fe);
  38.   endfunction
  39.  
  40.     //FONDU SORTIE//
  41.   function y=fondu_sortie(x)
  42.    y=reverse(fondu_entree(reverse(x)));
  43.      // playsnd(y,Fe);
  44.   endfunction
  45.  
  46.   //INVERSION
  47.     function y=reverse(x)
  48.         y=x(:,$:-1:1);
  49.       //  playsnd(y,Fe);
  50.     endfunction
  51.    
  52.     //TREMOLO//
  53.     function y=tremolo(x)
  54.         nb_ech=size(x,2);
  55.         ligne=size(x,1);
  56.         Te=1/Fe
  57.         A=input('Veuillez choisir l amplitude de trémolo:');
  58.         f=input('Veuillez choisir la fréquence du trémolo:');
  59.         t=[0:nb_ech-1]*Te;
  60.         trem=A*(1-cos(2*%pi*f*t));
  61.         trem_2=[];
  62.         for k=1:ligne
  63.             trem_2=[trem_2;trem]
  64.         end
  65.         y=x.*trem_2;
  66.     endfunction
  67.    
  68.     //CHORUS//
  69. function y=chorus(x)
  70.     tps=input('Rentrez une valeur entre 50 et 200ms')/1000;
  71.     N=round(Fe*tps);
  72.     x_decale=[zeros(size(x,1), N) x];
  73.     y=x+x_decale(:,1:$-N);
  74. endfunction
  75.    
  76.     //BRUIT//
  77. function y=bruit(x)
  78.     taux_bruit=input('Entrez le pourcentage de bruit à ajouter en %');
  79.     A=taux_bruit/100*abs(max(x));
  80.     y=x+A*(rand(size(x, 1), size(x, 2))-rand(size(x, 1));
  81. endfunction
  82.  
  83.  
  84.     //NORMALISATION//
  85. function y=normalisation(x)
  86.     A=max(abs(max(x)), abs(min(x));
  87.     y=x/A;
  88. endfunction
  89.    
  90.    
  91.    
  92.    
  93.    
  94.     printf('Choisi un effet a appliquer parmi les suivant: \n\n')
  95.     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 " )
  96.    
  97.     select effet
  98.     case 1 then
  99.        y=sous_ech(chanson);
  100.        playsnd(y,Fe/N);
  101.     case 2 then
  102.        y=sous_quant(chanson);
  103.        playsnd(y,Fe);
  104.     case 3 then
  105.         y=fondu_entree(chanson);
  106.         playsnd(y,Fe);
  107.     case 4 then
  108.         y=fondu_sortie(chanson);
  109.         playsnd(y,Fe);
  110.     case 5 then
  111.         y=inversion(chanson);
  112.         playsnd(y,Fe);
  113.     case 6 then
  114.         y=tremolo(chanson);
  115.         playsnd(y,Fe);
  116.     case 7 then
  117.         y=chorus(chanson);
  118.         playsnd(y,Fe);
  119.     case 8 then
  120.         y=bruit(chanson);
  121.         playsnd(y,Fe);
  122.     case 9 then
  123.         y=noramlisation
  124.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement