UpDownMix - Script audio AviSynth

Modérateur : Modérateurs

Répondre
Avatar du membre
leon1789
Messages : 775
Enregistré le : dim. 26 août, 2007 14:09
Contact :

UpDownMix - Script audio AviSynth

Message par leon1789 »

Bonjour

Voici un script (un peu trop long) pour un traitement audio avec avisynth. La fonction UpDownMix permet de modifier le nombre de canaux audio (augmenter ou diminuer).

Exemples d'utilisation :
Source.UpDownMix(normalise=true) --> créer une vidéo dont l'audio est boostée au maximum sans saturation (-> normalisée)
Source.UpDownMix(1.0) --> créer une vidéo dont l'audio est en mono
Source.UpDownMix(2.0) --> créer une vidéo dont l'audio est en stéréo
Source.UpDownMix(3.0, "ac3", normalise=true) --> créer une vidéo dont l'audio est normalisée et pourra être encodée en 3.0 ac3
Source.UpDownMix(5.1, "aac") --> créer une vidéo dont l'audio pourra être encodée en 5.1 aac

Code : Tout sélectionner

#
# UpDownMix(clip Video, float "sortie", string "format", bool "normalise")  
#
# - Video (obligatoire) désigne la vidéo à traiter ayant de l'audio 
# format wav comptant entre 1 et 6 canaux.
#
# - sortie (optionnel) désigne les canaux de sortie : 
#         1.0, 2.0, 3.0, 4.0, 5.0, 5.1 (défaut = idem que video)
#
# - format (optionnel) désigne l'ordre désiré des canaux,
#         "wav" (=défaut), "ac3" pour tout type de sortie
#         "ogg", "dts", "aac", "aiff" pour les sortie 1.0, 2.0, 4.0, 5.1
#
# - normalise (optionnel) commande un boost maximum sans saturation
#         true, false (=défaut)
#
# Canaux d'entrée : entre 1 et 6
# Format d'entrée : wav
#
# Canaux de sortie :
#
#   1.0 (C)  
#
#   2.0 (L,R)  
#
#   3.0 "wav"=(L,R,C)  
#       "ac3"=(L,C,R)  
#
#   4.0 (L,R,SL,SR)  
#
#   5.0 "wav"=(L,R,C,SL,SR)  
#       "ac3"=(L,C,R,SL,SR)  
#
#   5.1 "wav"=(L,R,C,SW,SL,SR)
#       "ac3"="ogg"=(L,C,R,SL,SR,SW)
#       "dts"="aac"=(C,L,R,SL,SR,SW)
#       "aiff"=(L,SL,C,R,SR,SW)

function from10toN(clip Video, int N) 
{
  C = GetChannel(Video, 1) 
  return N==1 ? C :\
         N==2 ? MergeChannels(C,C) :\
         N==3 ? MergeChannels(C,C,C) :\
         N==4 ? MergeChannels(C,C,C,C) :\
         N==5 ? MergeChannels(C,C,C,C,C) :\
         MergeChannels(C,C,C,C,C,C)
}

function from20to10(clip Video) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2) 
  return MixAudio(L,R)
}

function from20to20(clip Video) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2) 
  return MergeChannels(L,R)
}

function from20to30(clip Video, string format) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2)
  C = MixAudio(L, R)
  return format=="ac3" ? MergeChannels(L,C,R) :\
                         MergeChannels(L,R,C)
}

function from20to40(clip Video) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2)
  SL = L
  SR = R
  return MergeChannels(L,R,SL,SR)
}

function from20to50(clip Video, string format) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2)
  C = MixAudio(L, R)
  SL = L
  SR = R
  return format=="ac3" ? MergeChannels(L,C,R,SL,SR) :\
                         MergeChannels(L,R,C,SL,SR)
}

function from20to51(clip Video, string format) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2)
  C = MixAudio(L, R)
  SL = L
  SR = R
  SW = C
  return format=="ac3" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="ogg" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="dts" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aac" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aiff" ? MergeChannels( L, SL, C, R, SR, SW ) :\
                          MergeChannels( L, R, C, SW, SL, SR )
}

function from30to10(clip Video) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2) 
  C = GetChannel(Video, 3) 
  C = MixAudio(MixAudio(L, R), C, 2/3., 1/3.)
  return C
}

function from30to20(clip Video) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2) 
  C = GetChannel(Video, 3) 
  L = MixAudio(L, C, .5858, .4142)
  R = MixAudio(R, C, .5858, .4142)
  return MergeChannels(L,R)
}

function from30to30(clip Video, string format) 
{
  L = GetChannel(Video, 1) 
  R = GetChannel(Video, 2) 
  C = GetChannel(Video, 3) 
  return format=="ac3" ? MergeChannels(L,C,R) :\
                         MergeChannels(L,R,C)
}

function from30to40(clip Video) 
{
  SL = GetChannel(Video, 1) 
  SR = GetChannel(Video, 2) 
  C  = GetChannel(Video, 3) 
  L  = MixAudio(SL, C, .268, .732)
  R  = MixAudio(SR, C, .268, .732)
  return MergeChannels(L,R,SL,SR)
}

function from30to50(clip Video, string format) 
{
  SL = GetChannel(Video, 1) 
  SR = GetChannel(Video, 2) 
  C  = GetChannel(Video, 3) 
  L  = MixAudio(SL, C, .5858, .4142)
  R  = MixAudio(SR, C, .5858, .4142)
  return format=="ac3" ? MergeChannels(L,C,R,SL,SR) :\
                         MergeChannels(L,R,C,SL,SR)
}

function from30to51(clip Video, string format) 
{
  SL = GetChannel(Video, 1) 
  SR = GetChannel(Video, 2) 
  C  = GetChannel(Video, 3) 
  L  = MixAudio(SL, C, .6077, .3923)
  R  = MixAudio(SR, C, .6077, .3923)
  SW = MixAudio(L,R)
  return format=="ac3" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="ogg" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="dts" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aac" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aiff" ? MergeChannels( L, SL, C, R, SR, SW ) :\
                          MergeChannels( L, R, C, SW, SL, SR )
}

function from40to10(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2) 
  SL = GetChannel(Video, 3) 
  SR = GetChannel(Video, 4) 
  L  = MixAudio(L, SL)
  R  = MixAudio(R, SR)
  return MixAudio(L,R)
}

function from40to20(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2) 
  SL = GetChannel(Video, 3) 
  SR = GetChannel(Video, 4) 
  L  = MixAudio(L, SL)
  R  = MixAudio(R, SR)
  return MergeChannels(L,R)
}

function from40to30(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2) 
  SL = GetChannel(Video, 3) 
  SR = GetChannel(Video, 4) 
  C  = MixAudio(L, R)
  L  = MixAudio(L, SL, .375, .625)
  R  = MixAudio(R, SR, .375, .625)
  return format=="ac3" ? MergeChannels(L,C,R) :\
                         MergeChannels(L,R,C)
}

function from40to40(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2) 
  SL = GetChannel(Video, 3) 
  SR = GetChannel(Video, 4) 
  return MergeChannels(L,R,SL,SR)
}

function from40to50(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2) 
  SL = GetChannel(Video, 3) 
  SR = GetChannel(Video, 4) 
  C  = MixAudio(L, R)
  L  = MixAudio(L, SL, .875, .125)   
  R  = MixAudio(R, SR, .875, .125)   
  return format=="ac3" ? MergeChannels(L,C,R,SL,SR) :\
                         MergeChannels(L,R,C,SL,SR)
}

function from40to51(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2) 
  SL = GetChannel(Video, 3) 
  SR = GetChannel(Video, 4) 
  C  = MixAudio(L,R)
  L  = MixAudio(L, SL, .75, .25)   
  R  = MixAudio(R, SR, .75, .25)   
  SW = C
  return format=="ac3" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="ogg" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="dts" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aac" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aiff" ? MergeChannels( L, SL, C, R, SR, SW ) :\
                          MergeChannels( L, R, C, SW, SL, SR )
}

function from50to10(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3) 
  SL = GetChannel(Video, 4) 
  SR = GetChannel(Video, 5) 
  L  = MixAudio(L, SL)
  R  = MixAudio(R, SR)
  C  = MixAudio(MixAudio(L,R), C, 4/5., 1/5.)
  return C
}

function from50to20(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3) 
  SL = GetChannel(Video, 4) 
  SR = GetChannel(Video, 5) 
  L  = MixAudio(MixAudio(L, SL), C, .7388, .2612)
  R  = MixAudio(MixAudio(R, SR), C, .7388, .2612)
  return MergeChannels(L,R)
}

function from50to30(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3) 
  SL = GetChannel(Video, 4) 
  SR = GetChannel(Video, 5) 
  C  = MixAudio(MixAudio(L, R), C, .472, .528) 
  L  = MixAudio(L, SL, .472, .528)
  R  = MixAudio(R, SR, .472, .528)
  return format=="ac3" ? MergeChannels(L,C,R) :\
                         MergeChannels(L,R,C)
}

function from50to40(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3) 
  SL = GetChannel(Video, 4) 
  SR = GetChannel(Video, 5) 
  SL = MixAudio(SL, L, .6471, .3529)
  SR = MixAudio(SR, R, .6471, .3529)
  L  = MixAudio(L, C, .5424, .4576)
  R  = MixAudio(R, C, .5424, .4576)
  return MergeChannels(L,R,SL,SR)
}

function from50to50(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3) 
  SL = GetChannel(Video, 4) 
  SR = GetChannel(Video, 5) 
  return format=="ac3" ? MergeChannels(L,C,R,SL,SR) :\
                         MergeChannels(L,R,C,SL,SR)
}

function from50to51(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3) 
  SL = GetChannel(Video, 4) 
  SR = GetChannel(Video, 5) 
  SW = MixAudio(L,R)
  return format=="ac3" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="ogg" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="dts" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aac" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aiff" ? MergeChannels( L, SL, C, R, SR, SW ) :\
                          MergeChannels( L, R, C, SW, SL, SR )
}

function from51to10(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3)
  SW = GetChannel(Video, 4) 
  SL = GetChannel(Video, 5) 
  SR = GetChannel(Video, 6)
  LR = MixAudio(MixAudio(L, SL), MixAudio(R, SR))
  C  = MixAudio(C, SW)
  return MixAudio(LR, C, 4/6., 2/6.)
}

function from51to20(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3)
  SW = GetChannel(Video, 4) 
  SL = GetChannel(Video, 5) 
  SR = GetChannel(Video, 6)
  C  = MixAudio(C, SW)
  L  = MixAudio(MixAudio(L, SL), C, .5858, .4142)
  R  = MixAudio(MixAudio(R, SR), C, .5858, .4142)
  return MergeChannels(L,R)
}

function from51to30(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3)
  SW = GetChannel(Video, 4) 
  SL = GetChannel(Video, 5) 
  SR = GetChannel(Video, 6)
  C  = MixAudio(MixAudio(L, R), C, .5858, .4142)
  L  = MixAudio(MixAudio(L, SW), SL, .5858, .4142)
  R  = MixAudio(MixAudio(R, SW), SR, .5858, .4142)
  return format=="ac3" ? MergeChannels(L,C,R) :\
                         MergeChannels(L,R,C)
}

function from51to40(clip Video) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3)
  SW = GetChannel(Video, 4) 
  SL = GetChannel(Video, 5) 
  SR = GetChannel(Video, 6)
  C  = MixAudio(C, SW)
  SL = MixAudio(SL, L, .531, .469)
  SR = MixAudio(SR, R, .531, .469)
  L  = MixAudio(L, C, .249, .751)
  R  = MixAudio(R, C, .249, .751)
  return MergeChannels(L,R,SL,SR)
}

function from51to50(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3)
  SW = GetChannel(Video, 4) 
  SL = GetChannel(Video, 5) 
  SR = GetChannel(Video, 6)
  C  = MixAudio(MixAudio(L,R), C, .3422, .6578)
  SL = MixAudio(SL, L, .6578, .3422)
  SR = MixAudio(SR, R, .6578, .3422)
  L  = MixAudio(L, SW, .5349, .4651)
  R  = MixAudio(R, SW, .5349, .4651)
  return format=="ac3" ? MergeChannels(L,C,R,SL,SR) :\
                         MergeChannels(L,R,C,SL,SR)
}

function from51to51(clip Video, string format) 
{
  L  = GetChannel(Video, 1) 
  R  = GetChannel(Video, 2)
  C  = GetChannel(Video, 3)
  SW = GetChannel(Video, 4) 
  SL = GetChannel(Video, 5) 
  SR = GetChannel(Video, 6)
  return format=="ac3" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="ogg" ? MergeChannels( L, C, R, SL, SR, SW ) :\
         format=="dts" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aac" ? MergeChannels( C, L, R, SL, SR, SW ) :\
         format=="aiff" ? MergeChannels( L, SL, C, R, SR, SW ) :\
                          MergeChannels( L, R, C, SW, SL, SR )
}

function UpDownMix(clip Video, float "sortie", string "format", bool "normalise")  
{
  sac = Video.AudioChannels
  sortie = Defined(sortie) ? ceil(sortie) : sac
  format = Default(format, "wav")
  normalise = Default(normalise, false)

  A = sac==1 ? from10toN(Video, sortie) :\
      sac==2 ? sortie==1 ? from20to10(Video) :\
               sortie==2 ? from20to20(Video) :\
               sortie==3 ? from20to30(Video, format) :\
               sortie==4 ? from20to40(Video, format) :\
               sortie==5 ? from20to50(Video, format) :\
               sortie==6 ? from20to51(Video, format) :\
               nop :\
      sac==3 ? sortie==1 ? from30to10(Video) :\
               sortie==2 ? from30to20(Video) :\
               sortie==3 ? from30to30(Video, format) :\
               sortie==4 ? from30to40(Video) :\
               sortie==5 ? from30to50(Video, format) :\
               sortie==6 ? from30to51(Video, format) :\
               nop :\
      sac==4 ? sortie==1 ? from40to10(Video) :\
               sortie==2 ? from40to20(Video) :\
               sortie==3 ? from40to30(Video, format) :\
               sortie==4 ? from40to40(Video) :\
               sortie==5 ? from40to50(Video, format) :\
               sortie==6 ? from40to51(Video, format) :\
               nop :\
      sac==5 ? sortie==1 ? from50to10(Video) :\
               sortie==2 ? from50to20(Video) :\
               sortie==3 ? from50to30(Video, format) :\
               sortie==4 ? from50to40(Video) :\
               sortie==5 ? from50to50(Video, format) :\
               sortie==6 ? from50to51(Video, format) :\
               nop :\
      sac==6 ? sortie==1 ? from51to10(Video) :\
               sortie==2 ? from51to20(Video) :\
               sortie==3 ? from51to30(Video, format) :\
               sortie==4 ? from51to40(Video) :\
               sortie==5 ? from51to50(Video, format) :\
               sortie==6 ? from51to51(Video, format) :\
               nop :\
      nop

  A = normalise ? A.Normalize : A

  Try {Video = Video.HasVideo ? AudioDub( Video, A ) : A 
      }
  Catch(erreur)
      {Video = AudioDub( Video, A )
      }
  return Video
}

function TestChannels( int N, float "volume" )
{# original from DIRK-PITT 
 # N entier compris entre 1 et 6
 # le script renvoie vidéo + audio wav

  S=Tone( 10.0, 440, 48000, 1, "Silence", 0.0 )
  volume = Default(volume, 0.5)
  # === Video ==========================================================
  V1=MessageClip( "left / canal 1", 360, 200 ).ChangeFPS( 25 )
  V2=MessageClip( "right / canal 2", 360, 200 ).ChangeFPS( 25 )
  V3=MessageClip( "centre / canal 3", 360, 200 ).ChangeFPS( 25 )
  V4=MessageClip( "subwoofer / canal 4", 360, 200 ).ChangeFPS( 25 )
  V5=MessageClip( "sur.left / canal 5", 360, 200 ).ChangeFPS( 25 )
  V6=MessageClip( "sur.right / canal 6", 360, 200 ).ChangeFPS( 25 )
  V=ConvertToYV12(V1++V2++V3++V4++V5++V6)
  # === Audio ==========================================================
  L=Tone( 10.0, 440, 48000, 1, "Sine", volume )++S++S++S++S++S
  R=S++Tone( 10.0, 440, 48000, 1, "Triangle", volume )++S++S++S++S
  C=S++S++Tone( 10.0, 440, 48000, 1, "Sawtooth", volume )++S++S++S
  SW=S++S++S++Tone( 10.0, 110, 48000, 1, "Noise", volume )++S++S
  SL=S++S++S++S++Tone( 10.0, 880, 48000, 1, "Sine", volume )++S
  SR=S++S++S++S++S++Tone( 10.0, 880, 48000, 1, "Triangle", volume )  
  # === Result =========================================================  
  Return N==1 ? AudioDub( V, C ) :\
         N==2 ? AudioDub( V, MergeChannels( L, R ) ) :\
         N==3 ? AudioDub( V, MergeChannels( L, R, C ) ) :\
         N==4 ? AudioDub( V, MergeChannels( L, R, SL, SR ) ) :\
         N==5 ? AudioDub( V, MergeChannels( L, R, C, SL, SR ) ) :\
                AudioDub( V, MergeChannels( L, R, C, SW, SL, SR ) )
}
PS : ma femme me dit qu'elle préfère quand je fais du traitement d'image... :beuh:
Modifié en dernier par leon1789 le mar. 15 avr., 2008 19:10, modifié 3 fois.
Avatar du membre
Underground78
Administrateur
Administrateur
Messages : 11272
Enregistré le : mar. 06 févr., 2007 21:54
Localisation : France
Contact :

Message par Underground78 »

C'est un peu long effectivement ... :gy: :mrgreen:
beuz29
Messages : 167
Enregistré le : mar. 01 avr., 2008 12:07

Message par beuz29 »

tu m'étonnes !! :d:
??? oO ???
-
Avatar du membre
leon1789
Messages : 775
Enregistré le : dim. 26 août, 2007 14:09
Contact :

Message par leon1789 »

:o: Avec la fonction TestChannels suivante (provenant de http://www.forum.m4ng.fr/test-6-canaux-vt953.html), on crée une petite vidéo TestChannels(N) d'une minute avec N canaux audios (N compris entre 1 et 6)

Avec ça, on peut avoir un petit aperçu de la fonction UpDownMix :
TestChannels(2).UpDownMix(5.1) fait une petite simulation d'un upMix 2.0 -> 5.1
TestChannels(4).UpDownMix(3.0) fait une petite simulation d'un downMix 4.0 -> 3.0
TestChannels(6, 0.1).UpDownMix(3.0,normalise=true) fait une petite simulation d'un downMix 5.1 -> 3.0 avec normalisation

Code : Tout sélectionner

function TestChannels( int N, float "volume" )
{# original from DIRK-PITT 
 # N entier compris entre 1 et 6
 # le script renvoie vidéo + audio wav

  S=Tone( 10.0, 440, 48000, 1, "Silence", 0.0 )
  volume = Default(volume, 0.5)
  # === Video ==========================================================
  V1=MessageClip( "left / canal 1", 360, 200 ).ChangeFPS( 25 )
  V2=MessageClip( "right / canal 2", 360, 200 ).ChangeFPS( 25 )
  V3=MessageClip( "centre / canal 3", 360, 200 ).ChangeFPS( 25 )
  V4=MessageClip( "subwoofer / canal 4", 360, 200 ).ChangeFPS( 25 )
  V5=MessageClip( "sur.left / canal 5", 360, 200 ).ChangeFPS( 25 )
  V6=MessageClip( "sur.right / canal 6", 360, 200 ).ChangeFPS( 25 )
  V=ConvertToYV12(V1++V2++V3++V4++V5++V6)
  # === Audio ==========================================================
  L=Tone( 10.0, 440, 48000, 1, "Sine", volume )++S++S++S++S++S
  R=S++Tone( 10.0, 440, 48000, 1, "Triangle", volume )++S++S++S++S
  C=S++S++Tone( 10.0, 440, 48000, 1, "Sawtooth", volume )++S++S++S
  SW=S++S++S++Tone( 10.0, 110, 48000, 1, "Noise", volume )++S++S
  SL=S++S++S++S++Tone( 10.0, 880, 48000, 1, "Sine", volume )++S
  SR=S++S++S++S++S++Tone( 10.0, 880, 48000, 1, "Triangle", volume )  
  # === Result =========================================================  
  Return N==1 ? AudioDub( V, C ) :\
         N==2 ? AudioDub( V, MergeChannels( L, R ) ) :\
         N==3 ? AudioDub( V, MergeChannels( L, R, C ) ) :\
         N==4 ? AudioDub( V, MergeChannels( L, R, SL, SR ) ) :\
         N==5 ? AudioDub( V, MergeChannels( L, R, C, SL, SR ) ) :\
                AudioDub( V, MergeChannels( L, R, C, SW, SL, SR ) )
}
Avatar du membre
leon1789
Messages : 775
Enregistré le : dim. 26 août, 2007 14:09
Contact :

Message par leon1789 »

D'ailleurs, voici quelques tables (les plus amusantes :yeap: ) de mixage up ou down
Les canaux d'entrée sont L,C,R,... et ceux de sortie sont L', C', R', ...
Les tables représentent le poids de chaque canaux d'entrée dans chacun des canaux de sortie.

Les tables passant d'une entrée 3.0 à une sortie 2.0 ou 3.0 ou 4.0 ou 5.0 ou 5.1 [lightbox]http://img379.imageshack.us/img379/8610/30av5.th.jpg[/lightbox]

Les tables passant d'une entrée 4.0 à une sortie 2.0 ou 3.0 ou 4.0 ou 5.0 ou 5.1 [lightbox]http://img247.imageshack.us/img247/8568/40tn8.th.jpg[/lightbox]

Les tables passant d'une entrée 5.0 à une sortie 2.0 ou 3.0 ou 4.0 ou 5.0 [lightbox]http://img387.imageshack.us/img387/5641/50sj2.th.jpg[/lightbox]

Les tables passant d'une entrée 5.1 à une sortie 2.0 ou 3.0 ou 4.0 ou 5.0 [lightbox]http://img387.imageshack.us/img387/3324/51av6.th.jpg[/lightbox]
Avatar du membre
Underground78
Administrateur
Administrateur
Messages : 11272
Enregistré le : mar. 06 févr., 2007 21:54
Localisation : France
Contact :

Message par Underground78 »

Tu m'expliques comme ça marche ?
Avatar du membre
leon1789
Messages : 775
Enregistré le : dim. 26 août, 2007 14:09
Contact :

Message par leon1789 »

Pas de problème :)

Si tu prends un DVD habituel, il a une bande son 5.1 : on les note "à l'anglaise" les principaux L, C, R, les surround SL, SR, et SW pour le caisson de basse (approximativement).

Imaginons par exemple que l'on veuille faire sortir ces 6 canaux sur seulement 3 : disons L', C', R' (parce qu'on ne possède ni caisson de basses ni enceintes surround... on n'est pas riche...)

Alors il faut mixer les six canaux (entrée L,C,R,SL,SR,SW) en 3 canaux (sortie L', C', R'). Le problème est de savoir comment s'y prendre pour :
-1- garder l'intégralité de l'ensemble sonore ;
-2- garder approximativement les proportions ;
-3- ne pas saturer la sortie, ou l'inverse, ne pas perdre non plus 40 dB.

Alors pour faire ce mixage, on prend une matrice de dimension 3x6 (3 lignes car 3 canaux de sortie, 6 colonnes car 6 canaux d'entrée) : précisément, il s'agit de la seconde dans cette liste http://img387.imageshack.us/my.php?image=51av6.jpg

Dans cette matrice (de downMix 5.1 -> 3.0), chaque ligne (correspond à un canal de sortie) donne les poids respectifs des canaux d'entrée à mixer (figurant en colonne).
Bon, en clair, ça donne
L' = 0.293*L + 0.414*SL + 0.293*SW
C' = 0.293*L + 0.414*C + 0.293*R
R' = 0.293*R + 0.414*SR + 0.293*SW


Autre exemple : un upmix de 3.0 à 4.0 ?
Sur ça http://img379.imageshack.us/my.php?image=30av5.jpg on voit que l'on peut prendre
L' = 0.268*L + 0.732*C
R' = 0.268*R + 0.732*C
SL' = L
SR' = R

Evidemment, il n'y a pas qu'une seule manière de réaliser un mixage N canaux --> P canaux. Il y a une affaire de goût personnel dans l'histoire qui laisse pas mal de choix malgré les contraintes -1- , -2- , -3-. AC3Filter a ses matrices, Azid d'autres, etc.
Avatar du membre
Underground78
Administrateur
Administrateur
Messages : 11272
Enregistré le : mar. 06 févr., 2007 21:54
Localisation : France
Contact :

Message par Underground78 »

Merci, mais en faites ma question était plus sur l'attribution des coeffs ? c'est mathématique et une question de gout c'est ça ?
Avatar du membre
leon1789
Messages : 775
Enregistré le : dim. 26 août, 2007 14:09
Contact :

Message par leon1789 »

ah ok ! :D

Oui, les coefficients sont obtenus par des règles mathématiques et un goût perso (et aussi suivant des normes Dolby, avec des coefficients négatifs notamment)

En ce qui concerne les mathématiques, je crois qu'il n'y a que deux règles fondamentales :
-1- sur une ligne, la somme des coefficients doit être inférieure à 1 (il y a risque de saturation si la somme est supérieure). De plus, il faut qu'au moins une des sommes soit égale à 1 (sinon il y a perte inutile de puissance si on peut dire).
-2- quand on additionne les carrés des coefficients de chaque colonne, on doit toujours obtenir la même constante. Cela traduit que les "proportions" sonores d'origine sont respectées.

En ce qui me concerne, j'ai choisi que
-3- tous canaux de sortie soient utilisés : ce n'est pas forcément le cas dans les matrices d'azid ou d'AC3Filter ;
-4- la somme des coefficients de chaque ligne soit exactement égale à 1 (utilisation maximale des canaux de sortie) ;
-5- le canal LFE soit uniquement refondu dans les canaux L et G (comme azid le fait dans toutes ses matrices) ;
-6- uniquement des coefficients positifs dans les matrices, car j'ai des doutes (manque d'expérience) sur le bon résultat de coefficients négatifs : j'ai peur du bruit de résonance ou de "casserole" ;
-7- d'avoir, quand on a le choix, le nombre "minimum acceptable" de coefficients dans les matrices (pour une implémentation simplifiée en avisynth)

Evidemment, on ne mélange pas les canaux de droite et de gauche, sauf pour mixer au centre. Etc.

Une fois tout ça traduit en équations, il faut résoudre des bons vieux systèmes... un peu prise de tête...
:mad:
Avatar du membre
Underground78
Administrateur
Administrateur
Messages : 11272
Enregistré le : mar. 06 févr., 2007 21:54
Localisation : France
Contact :

Message par Underground78 »

Oki, c'est exactement ce que je voulais savoir ! :)
Répondre