TGC Codebase Backup



MiXer by Anonymous Coder

3rd Feb 2005 14:16
Summary

you can mixed 2 sounds in same time, addition of the echo, changed the frequency...



Description

you can mixed 2 sounds in same time, addition of the echo, changed the frequency, changed the panoramic one. you can enregister starting from the microphone. The program read the mp3 and the wav files



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem * Title  : reglage
cls
set window on

sync on
set display mode 1280,1024,16
rem fenetre
set window layout 0,0,0
set window title "TranSonmation"
set window size 1280,1024
set window position 0,0
rem pour enregistrer
enre=1
nom$="sample"
sync on
max=len("Programme de transformation du son par Petit-Jean Nicolas.............................")
backdrop on
set text font "verdana"
color backdrop 0
do
x#=x#+50
a#=x#/100
set text size 10+(a#/2)
if inkey$()=""=o then exit
center text 1280/2,1024/2, left$("Programme de transformation du son par Petit-Jean Nicolas",a#)
if a#>max then exit
sync
loop



debut:
for x=1 to 10
if sound exist(x)=1 then delete sound x
next x

for x=15 to 25
if sound exist(x)=1 then delete sound x
next x

cls
backdrop off
print "******************************************"
print " Fichiers audio(wav,mp3)"
print "******************************************"
dir
input "Quelle fichier voulez-vous charger?>";file$
if file exist(file$+".wav")=0 then rate=1
if file exist(file$+".mp3")=0 then rate=1
if file exist(file$+".wav")=1 then rate=0
if file exist(file$+".mp3")=1 then rate=0

if rate=1
print "le fichier ";file$; " n'existe pas"
sleep 500
cls
goto debut
endif

input "Quelle fichier d'ambience voulez-vous charger?>";file2$
if file exist(file2$+".wav")=0 then rate=1
if file exist(file2$+".mp3")=0 then rate=1
if file exist(file2$+".wav")=1 then rate=0
if file exist(file2$+".mp3")=1 then rate=0


if rate=1 
print "le fichier d'ambience n'existe pas"
sleep 500
cls
goto debut
endif

print "chargement..."
sleep 100
print "chargement..."

if file exist(file$+".wav")=1 then load sound file$+".wav",1 
if file exist(file$+".mp3")=1 then load sound file$+".mp3",1 

if file exist(file2$+".wav")=1 then load sound file2$+".wav",15
if file exist(file2$+".mp3")=1 then load sound file2$+".mp3",15
 

for x=2 to 10
clone sound x,1
next x

for x2=16 to 25
clone sound x2,15
next x2

goto du_son
end

du_son:
rem texte
set text font "verdana"
set text size 15
rem sys
cls
backdrop on
color backdrop rgb(125,125,125)
rem menu

rem son1
volume=100
echo=1
record=0
rem son 2
volume2=100
echo2=0
rem original1

for x=1 to 10
freqorig=get sound speed(x)
panoorig=get sound pan(x)
frequence=get sound speed(x)
freq=frequence/250
panoramique=get sound pan(x)
pano=panoramique/100
volumeorig=get sound volume(x)
next x
rem original2

for x2=15 to 25
freqorig2=get sound speed(x2)
panoorig2=get sound pan(x2)
frequence2=get sound speed(x2)
freq2=frequence2/250
panoramique2=get sound pan(x2)
pano2=panoramique2/100
volumeorig2=get sound volume(x2)
next x2
rem play
do
gosub son1
gosub son2
gosub enregistrement

posx=mousex()
newx=mousex()
new1x=mousex()
new2x=mousex()
posy=mousey()

sync
loop
rem sous programme(programme en fin de compte....)
son1:
rem infos
rem vol
text 400,0,"volume :"+str$(volume)
rem pano
text 400,20,"Panoramique du son :"+str$(panoramique)
rem freq
text 400,40,"Frequence du son :"+str$(frequence) 
rem nom du morceau
text 400,60,"Titre du morceau :"+file$
rem nbr de son
text 400,80,"Nombre de son(s) jouer(1=default): "+str$(echo)
rem echo
echor=echo*10
if echor=10 then echor=0
text 400,100,"Saturation(x/100%) :"+str$(echor)+" %" 
rem espace entre chaque son
text 400,120,"echo prononcé "+str$(espace_e)+"millisecondes"
rem option
text 0,25,"jouer en boucle le morceau (1) , Retrouver(R)"  
text 0,25+35,"Pause du morceau (2)" 
text 0,25+35+35,"Arreter le morceau(3)"

text 0,0,"Charger un morceau(C)"
rem Charger un son
if inkey$()="c" then goto debut
rem retour a l original
if inkey$()="r"
rem frequence de depart
frequence=freqorig
freq=frequence/250
box 150,25+35+35+35+35+35,150+freq,25+35+35+35+35+35+10
rem panoramique de depart
panoramique=panoorig
pano=panoramique/100
box 250+pano,25+35+35+35+35,250+pano,25+35+35+35+35+10
rem volume de depart
volume=volumeorig
box 150,25+35+35+35,150+volume,25+35+35+35+10
endif

rem volume
text 0,25+35+35+35,"Volume sonore du son" : box 150,25+35+35+35,150+volume,25+35+35+35+10 :line 150,25+35+35+35+15,250,25+35+35+35+15
if posx>150 and posy>25+35+35+35 and posx<250 and posy<25+35+35+35+10 and mouseclick()=1 
volume=newx-150
if volume>100 then volume=100
endif

rem pano
text 0,25+35+35+35+35,"Panoramique du son" :box 250+pano,25+35+35+35+35,250+pano,25+35+35+35+35+10 : line 150,25+35+35+35+35+15,350,25+35+35+35+35+15 
center text 250,25+35+35+35+25,"M"
center text 150,25+35+35+35+25,"L"
center text 350,25+35+35+35+25,"R"
if posx>150 and posy>25+35+35+35+35 and posx<350 and posy<25+35+35+35+35+10 and mouseclick()=1 
pano=new2x-250
panoramique=pano*100
if panoramique>10000 then panoramique=10000
if panoramique<-10000 then panoramique=-10000
endif

rem frequence
text 0,25+35+35+35+35+35,"Frequence du son" : box 150,25+35+35+35+35+35,150+freq,25+35+35+35+35+35+10 : line 150,25+35+35+35+35+35+15,550,25+35+35+35+35+35+15
center text 150+freqorig/250,25+35+35+35+35+35+15,"O"
if posx>150 and posy>25+35+35+35+35+35 and posx<550 and posy<25+35+35+35+35+35+10 and mouseclick()=1 
freq=new1x-150
frequence=freq*250
if frequence<100 then frequence=100
if frequence>100000 then frequence=100000
endif
rem play
if inkey$()="1" 
for x=1 to echo
if sound paused(x)=1 then resume sound x
if sound playing(x)=0 

if espace_e<>0 then sleep espace_e
loop sound x
endif
next x
endif

rem echo
text 0,25+35+35+35+35+35+35,"Ajouter un son" : box 150,25+35+35+35+35+35+35,160,25+35+35+35+35+35+35+10 : box 200,25+35+35+35+35+35+35,210,25+35+35+35+35+35+35+10
rem flagrant ou pas l'echo
text 0,25+35+35+35+35+35+35+35,"Puissance de l'echo" :box 150,25+35+35+35+35+35+35+35,160,25+35+35+35+35+35+35+35+10 : box 200,25+35+35+35+35+35+35+35,210,25+35+35+35+35+35+35+35+10
if sound playing(1)=0
rem +
if posx>200 and posy>25+35+35+35+35+35+35+35 and posx<210 and posy<25+35+35+35+35+35+35+35+10 and mouseclick()=1 
espace_e=espace_e+1
if espace_e>1000 then espace_e=1000
endif
rem -
if posx>150 and posy>25+35+35+35+35+35+35+35 and posx<160 and posy<25+35+35+35+35+35+35+35+10 and mouseclick()=1 
espace_e=espace_e-1
if espace_e<0 then espace_e=0
endif
endif
if sound playing(1)=0
rem echo
if posx>200 and posy>25+35+35+35+35+35+35 and posx<210 and posy<25+35+35+35+35+35+35+10 and mouseclick()=1 
echo=echo+1
if echo>10 then echo=10
sleep 100
endif
if posx>150 and posy>25+35+35+35+35+35+35 and posx<160 and posy<25+35+35+35+35+35+35+10 and mouseclick()=1 
echo=echo-1
if echo<1 then echo=1
sleep 100
endif
endif

rem pause
if inkey$()="2" 
for x=1 to 10
if sound playing(x)=1 then pause sound x
next x
endif
rem stop
if inkey$()="3" 
for x=1 to 10
if sound playing(x)=1 then stop sound x
next x
endif

rem son
for x=1 to echo
set sound volume x,volume
rem -10000,10000
set sound pan x,panoramique
rem 100->100000
set sound speed x,frequence
next x
return


son2:
rem infos
rem vol
text 1000,0,"volume :"+str$(volume2)
rem pano
text 1000,20,"Panoramique du son :"+str$(panoramique2)
rem freq
text 1000,40,"Frequence du son :"+str$(frequence2) 
rem nom du morceau
text 1000,60,"Titre du morceau :"+file2$
rem nbr de son
text 1000,80,"Nombre de son(s) jouer(0=default): "+str$(echo2)
rem echo
echor2=echo2*10
text 1000,100,"Saturation(x/100%) :"+str$(echor2)+" %" 
rem espace entre chaque son
text 1000,120,"echo prononcé "+str$(espace_e2)+"millisecondes"
rem option
text 600,25,"Jouer en boucle le morceau (4) , Retrouver(O)"  
text 600,25+35,"Pause du morceau (5)" 
text 600,25+35+35,"Arreter le morceau(6)"

rem retour a l original
if inkey$()="o"
rem frequence de depart
frequence2=freqorig2
freq2=frequence2/250
box 750,25+35+35+35+35+35,750+freq2,25+35+35+35+35+35+10
rem panoramique de depart
panoramique2=panoorig2
pano2=panoramique2/100
box 750+pano2,25+35+35+35+35,750+pano2,25+35+35+35+35+10
rem volume de depart
volume2=volumeorig2
box 750,25+35+35+35,750+volume2,25+35+35+35+10
endif

rem volume
text 600,25+35+35+35,"Volume sonore du son" : box 750,25+35+35+35,750+volume2,25+35+35+35+10 :line 750,25+35+35+35+15,850,25+35+35+35+15
if posx>750 and posy>25+35+35+35 and posx<850 and posy<25+35+35+35+10 and mouseclick()=1 
volume2=newx-750
if volume2>100 then volume2=100
endif

rem pano
text 600,25+35+35+35+35,"Panoramique du son" :box 850+pano2,25+35+35+35+35,850+pano2,25+35+35+35+35+10 : line 750,25+35+35+35+35+15,950,25+35+35+35+35+15 
center text 850,25+35+35+35+25,"M"
center text 750,25+35+35+35+25,"L"
center text 950,25+35+35+35+25,"R"

if posx>750 and posy>25+35+35+35+35 and posx<950 and posy<25+35+35+35+35+10 and mouseclick()=1 
pano2=new2x-850

panoramique2=pano2*100
if panoramique2>10000 then panoramique2=10000
if panoramique2<-10000 then panoramique2=-10000
endif

rem frequence
text 600,25+35+35+35+35+35,"Frequence du son" : box 750,25+35+35+35+35+35,750+freq2,25+35+35+35+35+35+10 : line 750,25+35+35+35+35+35+15,1150,25+35+35+35+35+35+15
center text 750+freqorig2/250,25+35+35+35+35+35+15,"O"
if posx>750 and posy>25+35+35+35+35+35 and posx<1150 and posy<25+35+35+35+35+35+10 and mouseclick()=1 
freq2=new1x-750
frequence2=freq2*250
if frequence2<100 then frequence2=100
if frequence2>100000 then frequence2=100000
endif
rem play

if inkey$()="4" 
for x2=15 to 15+echo2
if sound paused(x2)=1 then resume sound x2
if sound playing(x2)=0 
if espace_e2<>0 then sleep espace_e2
loop sound x2
endif
next x2
endif

rem echo
text 600,25+35+35+35+35+35+35,"Ajouter un son" : box 750,25+35+35+35+35+35+35,760,25+35+35+35+35+35+35+10 : box 800,25+35+35+35+35+35+35,810,25+35+35+35+35+35+35+10
rem flagrant ou pas l'echo
text 600,25+35+35+35+35+35+35+35,"Puissance de l'echo" :box 750,25+35+35+35+35+35+35+35,760,25+35+35+35+35+35+35+35+10 : box 800,25+35+35+35+35+35+35+35,810,25+35+35+35+35+35+35+35+10
if sound playing(15)=0
rem +
if posx>800 and posy>25+35+35+35+35+35+35+35 and posx<810 and posy<25+35+35+35+35+35+35+35+10 and mouseclick()=1 
espace_e2=espace_e2+1
if espace_e2>1000 then espace_e2=1000
endif
rem -
if posx>750 and posy>25+35+35+35+35+35+35+35 and posx<760 and posy<25+35+35+35+35+35+35+35+10 and mouseclick()=1 
espace_e2=espace_e2-1
if espace_e2<0 then espace_e2=0
endif
endif
if sound playing(15)=0
rem echo
if posx>800 and posy>25+35+35+35+35+35+35 and posx<810 and posy<25+35+35+35+35+35+35+10 and mouseclick()=1 
echo2=echo2+1
if echo2>10 then echo2=10
sleep 100
endif
if posx>750 and posy>25+35+35+35+35+35+35 and posx<760 and posy<25+35+35+35+35+35+35+10 and mouseclick()=1 
echo2=echo2-1
if echo2<0 then echo2=0
sleep 100
endif
endif


rem pause
if inkey$()="5" 
for x=15 to 25
if sound playing(x)=1 then pause sound x
next x
endif
rem stop
if inkey$()="6" 
for x=15 to 25
if sound playing(x)=1 then stop sound x
next x
endif

rem son
for x2=15 to 15+echo2
set sound volume x2,volume2
rem -10000,10000
set sound pan x2,panoramique2
rem 100->100000
set sound speed x2,frequence2
next x2
return

enregistrement:
rem enregistrement
rem flagrant ou pas l'echo
text 0,25+35+35+35+35+35+35+35+35+35,"Enregistrer un son a partir du micro(e),(t) pour finir l'enregistrement"
if record=1 then text 0,25+35+35+35+35+35+35+35+35+35,"Un son est enregistrer a partir d'un micro "
if sound playing(1)=0

if record=0
if inkey$()="e"
record sound 11
enre=enre+1
sleep 100
record=1
endif
endif

if record=1
if inkey$()="t"
stop recording sound
record=0
save sound nom$+str$(enre)+".wav",11
endif
endif

endif
return