Jump to content

command line exe output to mem intsead of file?


Recommended Posts

Good Hi to you all,

Is it even possible to get a command line program that outputs to a file to output to a memory location instead? My feeble attempt follows:

Link to CenterCut

Link to BASS

Thanks,

Joe

;WinAPI coded by UEZ 2010
#include <WinAPI.au3>
#include <Bass.au3>
Opt('MustDeclareVars', 0)
OnAutoItExitRegister("ExitFunctions")
_BASS_Startup()
_BASS_Init($BASS_DEVICE_MONO, -1, 44100, 0, "")
Const $CC = @ScriptDir & "\CenterCutCl.exe"
$iFile = @ScriptDir & "\stereo.wav"
$oFile = @ScriptDir & "\mono.wav"
Dim $tfile
$file_size = FileGetSize($iFile)/2
If $file_size Then
    $tBuffer = DllStructCreate("byte[" & $file_size & "]")
    $pMem = DllStructGetPtr($tBuffer)
    Global $nBytes
    $hFile =_WinAPI_CreateFile($tfile, 2, 2)
    _WinAPI_SetFilePointer($hFile, 3)
    _WinAPI_ReadFile($hFile, $pMem, $file_size, $nBytes)
    _WinAPI_CloseHandle($hFile)
EndIf

If FileExists($oFile) Then FileDelete($oFile)


;~ ================ This doesn't work <==============
;~ RunWait($CC &  ' "' & $iFile &'"' & " -c " & '"' & $hFile & '"' ,@ScriptDir,@SW_HIDE)
;~ $FHnd = _BASS_StreamCreateFile(1,$pMem, 0, $file_size, $BASS_DEVICE_SPEAKERS)
;~ $dur = _BASS_ChannelGetLength($FHnd, $BASS_POS_BYTE)
;~ _BASS_ChannelPlay($FHnd, False)

;~ ================ This works but has to create a file <==============
RunWait($CC &  ' "' & $iFile &'"' & " -c " & '"' & $oFile & '"' ,@ScriptDir,@SW_HIDE)
$FHnd = _BASS_StreamCreateFile(0,$oFile, 0, 0, $BASS_DEVICE_SPEAKERS)
$dur = _BASS_ChannelGetLength($FHnd, $BASS_POS_BYTE)
_BASS_ChannelPlay($FHnd, False)

Do
     Sleep(50)
     $pos = _BASS_ChannelGetPosition($FHnd, $BASS_POS_BYTE)
Until $pos >= $dur
Exit

Func ExitFunctions ()
    _BASS_Stop()
    _BASS_Free()
EndFunc

Are you experienced?

Link to comment
Share on other sites

Now I've never used any of the DLL functions but from what I can tell you need to write to the struct using DLLStructSetData()? Don't quote me on this, I'm stabbing in the dark here.

Link to comment
Share on other sites

Take a look at the BassEnc examples.

You can set a cmdline-encoder on a channel, like: "lame.exe -b128 - - "

The first "-" tells lame that input = stdin, the second "-" that output=stdout

You have to test if centercut can handle input and output from stdin/out (helpfile!?)

EDIT:

here you can find a winamp-dsp-plugin: http://moitah.net/

that is based on VirtualDub CenterCut.

Maybe you can use it with BASS_WADSP.dll www.un4seen.com

Edited by eukalyptus
Link to comment
Share on other sites

Will this help you?

#include <Constants.au3>
Local $run = @ComSpec & " /c " & "dir c:\"
$prg = Run($run, @SystemDir, @SW_HIDE, $STDOUT_CHILD)
Local $line, $mem
While 1
    $line = StdoutRead($prg)
    If @error Then ExitLoop
    $mem &= $line
Wend

MsgBox(0, "", $mem)

BR,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks guys,

From what I've been able to test (there's nothing about it using the help switch), there is no option to output to stdout and his winamp plugin is old and buggy and doesn't sound as good as the recent version. I've posted a request on the VirtualDub forum where the program was introduced and have made a request to the author. I'm hopeful he'll add a switch because a friend of mine was recently able to get him to modify the GUI to create the cmd line version. He's posted the source code but I don't know the first thing about C programming.

Best to you all,

Joe

Are you experienced?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...