Twitter iPhone pliant OnePlus 12 PS5 Disney+ Orange Livebox Windows 11 ChatGPT

convertire un fichier wav en fichier mp3 et inversément

5 réponses
Avatar
Zazeglu
Bonjour,

qqun sait il si il est possible de convertire un fichier=20
wav en fichier mp3 et invers=E9ment avec Vb ?

Merci=20

Zazeglu

5 réponses

Avatar
Titeuf
lame.exe/dll http://lame.sourceforge.net/

lameX.ocx : http://www.interruptx.com/lamex.html

voila


------------------Zititeuf---------------
---http://www.perfectvb2k2.fr.st--
-----Merci de remplir le livre d'or-----
Avatar
Jonathan
Honnetement, ce contrôle ActiveX marche vraiment mal, j'ai testé la version
1.0 il y à quelque mois et soit ca marche pour un titre puis çà plante ou
soit ca plante directement en fermant l'application qui contient l'OCX. De
plus un grésillement se fait entendre à chaque début de fichier convertit.
Evitez ce truc pour un usage professionnel. Moi je fais maintenant appel à
une ligne de commande DOS qui execute LAME.EXE "Fichier1.wav" "Fichier2.mp3"
avec une pipe pour récupérer le pourcentage dans une textbox. Suivant un
module nommé MyDos bien connu. Depuis les encodages sont nickels et
l'utilisateur ne voit pas aucune fenetre DOS a part mon appli. Voila pour
ceux qui veulent des idées la dessus. Idem pour ToolAme (MPEG Audio Layer 2
Encoder)

@+

Jonathan
Avatar
Zazeglu
Bonjour,

ta méthode m'intéresse ,
Peut tu me dire comment tu fais ?

Merci

Zazeglu
-----Message d'origine-----
Honnetement, ce contrôle ActiveX marche vraiment mal,


j'ai testé la version
1.0 il y à quelque mois et soit ca marche pour un titre


puis çà plante ou
soit ca plante directement en fermant l'application qui


contient l'OCX. De
plus un grésillement se fait entendre à chaque début de


fichier convertit.
Evitez ce truc pour un usage professionnel. Moi je fais


maintenant appel à
une ligne de commande DOS qui execute


LAME.EXE "Fichier1.wav" "Fichier2.mp3"
avec une pipe pour récupérer le pourcentage dans une


textbox. Suivant un
module nommé MyDos bien connu. Depuis les encodages sont


nickels et
l'utilisateur ne voit pas aucune fenetre DOS a part mon


appli. Voila pour
ceux qui veulent des idées la dessus. Idem pour ToolAme


(MPEG Audio Layer 2
Encoder)

@+

Jonathan


.



Avatar
Jonathan
Dans une form (1 textbox + 4 boutons)


Private WithEvents MyDOS As DOSClass


Private Sub CmdQuitter_Click()
Unload Me
End Sub

Private Sub Form_Load()
Set MyDOS = New DOSClass
End Sub

Private Sub Form_Unload(Cancel As Integer)
MyDOS.ClosedCommand
Set MyDOS = Nothing
End Sub

Private Sub MyDOS_ReceiveOutputs(CommandOutputs As String)
If CommandOutputs <> "" Then TextDos = "": TextDos = CommandOutputs



End Sub

Private Sub Command1_Click()
TextDos = ""
MyDOS.CommandLine = "cmd.exe /C dir c:"
MyDOS.ExecuteCommand
End Sub

Private Sub Command2_Click()
TextDos = ""
MyDOS.CommandLine = "net.exe"
MyDOS.ExecuteCommand
End Sub

Private Sub Command3_Click()
TextDos = ""
MyDOS.CommandLine = "C:lame.exe " & Chr(34) & _
"Fichier.wav" & Chr(34) & " " & Chr(34) & "Fichier.mp3" & Chr(34)
MyDOS.ExecuteCommand
End Sub

Private Sub Command4_Click()
CommonDialog1.DialogTitle = "Choisir un programme de type 'dos'"
CommonDialog1.Filter = " Programmes |*.exe"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
TextDos = ""
MyDOS.CommandLine = CommonDialog1.FileName
MyDOS.ExecuteCommand
End If
End Sub









Dans un module:

Option Explicit
Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long,
phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize As Long) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, ByVal
lpBuffer As String, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead
As Long, ByVal lpOverlapped As Any) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Declare Function CreateProcessA Lib "kernel32" (ByVal
lpApplicationName As Long, ByVal lpCommandLine As String,
lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As
SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As
Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long,
lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION)
As Long
Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hHandle As Long)
As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const STARTF_USESTDHANDLES = &H100&
Private Const STARTF_USESHOWWINDOW = &H1
Private mCommand As String 'Variable privée contenant
la ligne de commande
Private mOutputs As String 'Variable privée pour la
lecture du texte renvoié
Private ProcI As PROCESS_INFORMATION 'Process utilisé
Private HLecturePipe As Long 'Handle de lecture du "pipe"
Private HEcriturePipe As Long 'Handle d'écriture du "pipe"
Public Event ReceiveOutputs(CommandOutputs As String)
Public Property Let CommandLine(DOSCommand As String)
mCommand = DOSCommand
End Property

Public Property Get CommandLine() As String
CommandLine = mCommand
End Property
Public Property Get Outputs()
Outputs = mOutputs
End Property
Public Function ExecuteCommand() As String
Dim Result As Long
Dim Start As STARTUPINFO
Dim Sa As SECURITY_ATTRIBUTES
Dim LngOctetRec As Long
Dim strBuff As String * 256
If Len(mCommand) = 0 Then
MsgBox "La commande à lancer n'a pas été renseignée!!!", vbCritical
Exit Function
End If
Sa.nLength = Len(Sa)
Sa.bInheritHandle = 1&
Sa.lpSecurityDescriptor = 0&
If CreatePipe(HLecturePipe, HEcriturePipe, Sa, 0) = 0 Then
MsgBox "Erreur de création du Pipe. Erreurr: " & Err.LastDllError,
vbCritical
Exit Function
End If
Start.cb = Len(Start)
Start.dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW
Start.hStdOutput = HEcriturePipe
Start.hStdError = HEcriturePipe
If CreateProcessA(0&, mCommand, Sa, Sa, 1&, NORMAL_PRIORITY_CLASS, 0&,
0&, Start, ProcI) <> 1 Then
Result = CloseHandle(HLecturePipe)
Result = CloseHandle(HEcriturePipe)
MsgBox "Fichier ou commande non trouvé.", vbCritical
Exit Function
End If
Result = CloseHandle(HEcriturePipe)
mOutputs = ""
Do
Result = ReadFile(HLecturePipe, strBuff, 256, LngOctetRec, 0&)
mOutputs = mOutputs & Left(strBuff, LngOctetRec)
RaiseEvent ReceiveOutputs(Left(strBuff, LngOctetRec))
DoEvents
Loop While Result <> 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
ExecuteCommand = mOutputs
End Function

Public Sub ClosedCommand()
Dim Result As Long
TerminateProcess ProcI.hProcess, 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
End Sub

Apres tu récupères les valeurs de la textbox pour l'afficher en barre de
progression .

@+

Jonathan
Avatar
Zazeglu
Merci

Zazeglu
-----Message d'origine-----
Dans une form (1 textbox + 4 boutons)


Private WithEvents MyDOS As DOSClass


Private Sub CmdQuitter_Click()
Unload Me
End Sub

Private Sub Form_Load()
Set MyDOS = New DOSClass
End Sub

Private Sub Form_Unload(Cancel As Integer)
MyDOS.ClosedCommand
Set MyDOS = Nothing
End Sub

Private Sub MyDOS_ReceiveOutputs(CommandOutputs As String)
If CommandOutputs <> "" Then TextDos = "": TextDos =


CommandOutputs



End Sub

Private Sub Command1_Click()
TextDos = ""
MyDOS.CommandLine = "cmd.exe /C dir c:"
MyDOS.ExecuteCommand
End Sub

Private Sub Command2_Click()
TextDos = ""
MyDOS.CommandLine = "net.exe"
MyDOS.ExecuteCommand
End Sub

Private Sub Command3_Click()
TextDos = ""
MyDOS.CommandLine = "C:lame.exe " & Chr(34) & _
"Fichier.wav" & Chr(34) & " " & Chr(34)


& "Fichier.mp3" & Chr(34)
MyDOS.ExecuteCommand
End Sub

Private Sub Command4_Click()
CommonDialog1.DialogTitle = "Choisir un programme de


type 'dos'"
CommonDialog1.Filter = " Programmes |*.exe"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
TextDos = ""
MyDOS.CommandLine = CommonDialog1.FileName
MyDOS.ExecuteCommand
End If
End Sub









Dans un module:

Option Explicit
Private Declare Function CreatePipe Lib "kernel32"


(phReadPipe As Long,
phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize


As Long) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal


hFile As Long, ByVal
lpBuffer As String, ByVal nNumberOfBytesToRead As Long,


lpNumberOfBytesRead
As Long, ByVal lpOverlapped As Any) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Declare Function CreateProcessA Lib "kernel32"


(ByVal
lpApplicationName As Long, ByVal lpCommandLine As String,
lpProcessAttributes As SECURITY_ATTRIBUTES,


lpThreadAttributes As
SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal


dwCreationFlags As
Long, ByVal lpEnvironment As Long, ByVal


lpCurrentDirectory As Long,
lpStartupInfo As STARTUPINFO, lpProcessInformation As


PROCESS_INFORMATION)
As Long
Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32"


(ByVal hHandle As Long)
As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const STARTF_USESTDHANDLES = &H100&
Private Const STARTF_USESHOWWINDOW = &H1
Private mCommand As String 'Variable


privée contenant
la ligne de commande
Private mOutputs As String 'Variable


privée pour la
lecture du texte renvoié
Private ProcI As PROCESS_INFORMATION 'Process


utilisé
Private HLecturePipe As Long 'Handle


de lecture du "pipe"
Private HEcriturePipe As Long 'Handle


d'écriture du "pipe"
Public Event ReceiveOutputs(CommandOutputs As String)
Public Property Let CommandLine(DOSCommand As String)
mCommand = DOSCommand
End Property

Public Property Get CommandLine() As String
CommandLine = mCommand
End Property
Public Property Get Outputs()
Outputs = mOutputs
End Property
Public Function ExecuteCommand() As String
Dim Result As Long
Dim Start As STARTUPINFO
Dim Sa As SECURITY_ATTRIBUTES
Dim LngOctetRec As Long
Dim strBuff As String * 256
If Len(mCommand) = 0 Then
MsgBox "La commande à lancer n'a pas été


renseignée!!!", vbCritical
Exit Function
End If
Sa.nLength = Len(Sa)
Sa.bInheritHandle = 1&
Sa.lpSecurityDescriptor = 0&
If CreatePipe(HLecturePipe, HEcriturePipe, Sa, 0) = 0


Then
MsgBox "Erreur de création du Pipe. Erreurr: " &


Err.LastDllError,
vbCritical
Exit Function
End If
Start.cb = Len(Start)
Start.dwFlags = STARTF_USESTDHANDLES Or


STARTF_USESHOWWINDOW
Start.hStdOutput = HEcriturePipe
Start.hStdError = HEcriturePipe
If CreateProcessA(0&, mCommand, Sa, Sa, 1&,


NORMAL_PRIORITY_CLASS, 0&,
0&, Start, ProcI) <> 1 Then
Result = CloseHandle(HLecturePipe)
Result = CloseHandle(HEcriturePipe)
MsgBox "Fichier ou commande non trouvé.",


vbCritical
Exit Function
End If
Result = CloseHandle(HEcriturePipe)
mOutputs = ""
Do
Result = ReadFile(HLecturePipe, strBuff, 256,


LngOctetRec, 0&)
mOutputs = mOutputs & Left(strBuff, LngOctetRec)
RaiseEvent ReceiveOutputs(Left(strBuff,


LngOctetRec))
DoEvents
Loop While Result <> 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
ExecuteCommand = mOutputs
End Function

Public Sub ClosedCommand()
Dim Result As Long
TerminateProcess ProcI.hProcess, 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
End Sub

Apres tu récupères les valeurs de la textbox pour


l'afficher en barre de
progression .

@+

Jonathan


.