Jump to content

Recommended Posts

Posted

Wasn't directed at you in particular, just as a reminder for me (to finish), and so others know that it is being worked on (as to not have two people do the same thing.)

Are your issues fixed now?

Cheers,

Brett

Posted (edited)

Introducing Bass_WASAPI RC1.

Here is a new BASSWASAPI add-on, making it possible to use WASAPI output and input (available on Windows Vista and beyond) with BASS. Both exclusive and shared modes are supported, as are both output and input devices, as well as "loopback" devices (which capture the sound from output devices).

Unlike BASSASIO, BASSWASAPI does require BASS, and the BASSmix add-on is recommended too. WASAPI doesn't support arbitrary sample formats (like DirectSound does), and BASSWASAPI doesn't include built-in resampling capability; BASSmix can be used to handle resampling instead (as well as playing multiple sounds), as in the examples. A BASSmix update is also included in the package above, which adds a new feature (the BASS_Mixer_ChannelGetPositionEx function) to account for output latency when getting the position of a source channel; see the CONTEST example for a demonstration of using that.

The DLL itself is not a final release, so things may change. Once a stable version is released, this will be added into the full library.

This wrapper is currently untested... Any examples, suggestions, fixes are appreciated :mellow:

Download the RC1_1 here:

BASS_WASAPI_RC1_1.zip

Cheers,

Brett

EDIT: Forgot to add updated BassMix with the extra function.,,

Edited by BrettF
Posted (edited)

i refer to ...convert sampling rate of a wav file using bass.dll

I missed bassmix.dll. Now it works.

To get a better quality of audio output what should be done?

I tried to do the same thing with sox and saw that its quality is better with the same parameters.

Edited by nico18n
Posted (edited)

Moitah, the author of CenterCutGUI, was kind enough to add a stdin and stdout switch at my request and it works fine via dos.

Per Eucalyptus's suggestion I tried to incorporate it with BASSEnc but I can't get it to work. I'm also unable to use any of the BassEncConstants without undefined function errors. The only way to get them to recognized is to include BassEncConstants.

The lone example in the zip file is not enough for me figure this out.

Link to CenterCutGui 1.6.0 (also includes CenterCutCL)

Please help! :mellow:

Thanks,

Joe

#include <Bass.au3>
#include <BassMix.au3>
#include <BassEnc.au3>

_BASS_STARTUP()

_BASS_Encode_STARTUP()
$basscb_dll = DllOpen("BASSCB.dll") ;DO I NEED THIS?

Global $ChHandle,$EncHandle,$Channel1,$dur,$pos
_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0,"")
$ChHandle= _BASS_StreamCreate(44100,2,0,0,0)

$EncHandle = _BASS_Encode_Start($ChHandle, 'CenterCutCl Stereo.wav -c stdout ', 0)
$Channel1 = _BASS_Encode_GetChannel($EncHandle)
$dur = _BASS_ChannelGetLength($Channel1, $BASS_POS_BYTE)
_BASS_ChannelPlay($Channel1, False)

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

Func ExitFunctions ()
    _BASS_Stop()
    _BASS_Free()
EndFunc
Edited by a440hz

Are you experienced?

Posted (edited)

Brett,

I was wondering why my channel assignments weren't working correctly in Windows 7. So this should help or should I just try to figure out BASSASIO? I DL the file but no examples. Can you tell me what I would modify to use your MultiChannelViewer.au3?

All the best,

Joe

Introducing Bass_WASAPI RC1.

The DLL itself is not a final release, so things may change. Once a stable version is released, this will be added into the full library.

This wrapper is currently untested... Any examples, suggestions, fixes are appreciated :mellow:

Download the RC1_1 here:

BASS_WASAPI_RC1_1.zip

Cheers,

Brett

EDIT: Forgot to add updated BassMix with the extra function.,,

Edited by a440hz

Are you experienced?

Posted

Moitah, the author of CenterCutGUI, was kind enough to add a stdin and stdout switch at my request and it works fine via dos.

Per Eucalyptus's suggestion I tried to incorporate it with BASSEnc but I can't get it to work. I'm also unable to use any of the BassEncConstants without undefined function errors. The only way to get them to recognized is to include BassEncConstants.

The lone example in the zip file is not enough for me figure this out.

Link to CenterCutGui 1.6.0 (also includes CenterCutCL)

Please help! :mellow:

Thanks,

Joe

#include <Bass.au3>
#include <BassMix.au3>
#include <BassEnc.au3>

_BASS_STARTUP()

_BASS_Encode_STARTUP()
$basscb_dll = DllOpen("BASSCB.dll") ;DO I NEED THIS?

Global $ChHandle,$EncHandle,$Channel1,$dur,$pos
_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0,"")
$ChHandle= _BASS_StreamCreate(44100,2,0,0,0)

$EncHandle = _BASS_Encode_Start($ChHandle, 'CenterCutCl Stereo.wav -c stdout ', 0)
$Channel1 = _BASS_Encode_GetChannel($EncHandle)
$dur = _BASS_ChannelGetLength($Channel1, $BASS_POS_BYTE)
_BASS_ChannelPlay($Channel1, False)

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

Func ExitFunctions ()
    _BASS_Stop()
    _BASS_Free()
EndFunc

Can you make it work with the GUI interface?

Brett,

I was wondering why my channel assignments weren't working correctly in Windows 7. So this should help or should I just try to figure out BASSASIO? I DL the file but no examples. Can you tell me what I would modify to use your MultiChannelViewer.au3?

All the best,

Joe

No idea. I haven't even looked at examples yet... Can you post your code? At least that way I might be able to figure something out :P
Posted

Can you make it work with the GUI interface?

No idea. I haven't even looked at examples yet... Can you post your code? At least that way I might be able to figure something out :mellow:

Oh sure, I was using it with the GUI from the get go. I don't want anything popping up though - I need to stream everything without saving any files.

Are you experienced?

Posted

What you want to do is realy, realy complicated.

maybe it works like this:

First create a stream from the stereofile with _BASS_StreamCreateFile

Then set CenterCutCL as encoder on this stream: _BASS_Encode_Start($stream, 'CenterCutCl stdin -c stdout -o', 0, "_EncCallBack")

(You will receive the processed data in the callback-function _EncCallBack)

Create another stream by using _BASS_StreamCreateFileUser

Inside _EncCallBack you have to push the data to the FileUserStream: _BASS_StreamPutFileData

BUT:

there is an unfixed error in _BASS_Encode_Start DllCallBackRegister: "dword;dword;ptr;dword;ptr"

_BASS_StreamCreateFileUser is not implemented yet

AutoIt is to slow to handle big amount of sampledata in a callback function.

(but this could be done by using an external dll...)

To use _BASS_StreamCreateFileUser you have to set up some more callback functions

(here you can take a look how to use _BASS_StreamCreateFileUser: #710665)

Posted

Can you make it work with the GUI interface?

No idea. I haven't even looked at examples yet... Can you post your code? At least that way I might be able to figure something out :mellow:

My Bad. Once I updated HDAudio drivers all channels are assigned correctly!!

Are you experienced?

Posted

What you want to do is realy, realy complicated.

maybe it works like this:

First create a stream from the stereofile with _BASS_StreamCreateFile

Then set CenterCutCL as encoder on this stream: _BASS_Encode_Start($stream, 'CenterCutCl stdin -c stdout -o', 0, "_EncCallBack")

(You will receive the processed data in the callback-function _EncCallBack)

Create another stream by using _BASS_StreamCreateFileUser

Inside _EncCallBack you have to push the data to the FileUserStream: _BASS_StreamPutFileData

BUT:

there is an unfixed error in _BASS_Encode_Start DllCallBackRegister: "dword;dword;ptr;dword;ptr"

_BASS_StreamCreateFileUser is not implemented yet

AutoIt is to slow to handle big amount of sampledata in a callback function.

(but this could be done by using an external dll...)

To use _BASS_StreamCreateFileUser you have to set up some more callback functions

(here you can take a look how to use _BASS_StreamCreateFileUser: #710665)

Wow, it's complex! Monoceres writes amazing code but I'm not sure how to begin to decipher his example, which streams audio in little chunks, into what I need to do.

If I type the following into dos prompt, centercutcl stereo.wav -c stdout > mono.wav, the result saves the file. Is there any possible way just to pipe the stdout to RAM and stream that into a bass channel buffer instead of a file?

I found this but dont know C

char bigOutBuf[8192];

char savBuf[8192];

fflush(stdout);

setvbuf(stdout,bigOutBuf,IOFBF,8192);//stdout uses your buffer

//after each operation

strncpy(savBuf,bigOutBuf,8192);//won't flush until full or fflush called

//...

//at long last finished

setbuf(stdout,NULL);//reset to unnamed buffer

Sorry to be so dense! :mellow:

Are you experienced?

Posted (edited)

What is happening with output for it to be bad? I've never had a problem with the quality of it.

Hello brettf. Sorry for the delay.

my mistake was because I wanted a mono audio. But putting one I took only one channel (left or right). How do I get an audio mixing left and right way?

$hMixer = _BASS_Mixer_StreamCreate($rate,1, BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE))

Edited by nico18n
Posted

i think, you have to create a mixer with 1 channel, the input is a stereo stream.

Then use BASS_Mixer_ChannelSetMatrix to set a mixing matrix of this format: (psuedocode) float[1][2] = [ [ 0.5, 0.5 ] ]

Or use the flag $BASS_MIXER_DOWNMIX

$hMixer = _BASS_Mixer_StreamCreate($rate,1, BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE)) 

$hChannel = _BASS_Mixer_StreamAddChannel($hMixer, $hStream, $BASS_MIXER_DOWNMIX)

The matric would be creted this way (_BASS_Mixer_StreamAddChannel with flag $BASS_MIXER_MATRIX)

$tMatrix = DLLStructCreate("float[2]")
DLLStructSetData($tMatrix, 1, 0.5, 1)
DLLStructSetData($tMatrix, 1, 0.5, 2)
_BASS_Mixer_ChannelSetMatrix($hChannel, DLLStructGetPtr($tMatrix))

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

@nico18n:

SetMatrix($hMixer, 1, 1)

Func SetMatrix($handle, $left, $right)
    Local $tStruct = DllStructCreate("float;float")
    DllStructSetData($tStruct, 1, $left)
    DllStructSetData($tStruct, 2, $right)
    _BASS_Mixer_ChannelSetMatrix($handle, DllStructGetPtr($tStruct))
EndFunc   ;==>SetMatrix

btw.: BassMix resamples a lot of channels in realtime, so the algorithm is not as good as ffmpeg or sox etc...

--------------------------------------

@a440hz:

great idea, this should work:

#include "Bass.au3"
#include <Memory.au3>
#include <Constants.au3>

HotKeySet("{ESC}", "_Exit")

Global $hPid, $sStdout = "", $bStdout, $iSize
Global $hStream, $tStruct, $pStruct, $iPos


$hPid = Run("CenterCutCl stereo.wav -c stdout", @ScriptDir, @SW_SHOW, $STDOUT_CHILD)
While 1
    $sStdout &= StdoutRead($hPid)
    If @error Then ExitLoop
WEnd

$bStdout = StringToBinary($sStdout)
$iSize = BinaryLen($bStdout)
___DeBug(@error, "binarylen of stdout: " & $iSize)



_BASS_STARTUP()
___Debug(@error, "load bass.dll")

_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
___Debug(@error, "bass init")


$tStruct = DllStructCreate("byte[" & $iSize & "]")
DllStructSetData($tStruct, 1, $bStdout)
$pStruct = DllStructGetPtr($tStruct)

$hStream = _BASS_StreamCreateFile(True, $pStruct, 0, $iSize, 0)
___Debug(@error, "create stream from memory")

_BASS_ChannelPlay($hStream, 1)
___Debug(@error, "play stream from memory")

While _BASS_ChannelIsActive($hStream)
    $iPos = _BASS_ChannelGetPosition($hStream, $BASS_POS_BYTE)
    ___Debug(@error, "play from memory: " & Round($iPos * 100 / $iSize) & "% done")
    Sleep(20)
WEnd

_Exit()

Func _Exit()
    _BASS_StreamFree($hStream)
    ___Debug(@error, "free stream")

    _BASS_Free()
    ___Debug(@error, "free bass")

    Exit
EndFunc   ;==>_EXIT




Func ___DeBug($iError, $sAction)
    Switch $iError
        Case -1
            ConsoleWrite(@CRLF & "-" & $sAction & @CRLF)
        Case 0
            ConsoleWrite(@CRLF & "+" & $sAction & " - OK" & @CRLF)
        Case Else
            ConsoleWrite(@CRLF & "!" & $sAction & " - FAILED" & @CRLF)
            Exit
    EndSwitch
EndFunc   ;==>___DeBug

E

Posted

@eukalyptus: StdOutRead can directly read binary, so stringtobinary is not needed (StdOutRead($hPid, 0, 1))

Additionally it ould be better if you use a push-stream, so you don't have to wait for the completion of centercutcl

$hStream = _BASS_StreamCreate(44100, 2, 0, $STREAMPROC_PUSH, 0)
_BASS_StreamPutData($hStream, ...

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted (edited)

But you have to use _BASS_StreamCreateFileUser in this case and _BASS_StreamPutFileData to fill the streambuffer, isn´t it?!

And you will need some callback functions:

typedef struct {
    FILECLOSEPROC *close;
    FILELENPROC *length;
    FILEREADPROC *read;
    FILESEEKPROC *seek;
} BASS_FILEPROCS;

EDIT

THX, thx, thx Prog@ndy!!!

#include "Bass.au3"
#include <Memory.au3>
#include <Constants.au3>

HotKeySet("{ESC}", "_Exit")

Global $hPid, $bStdout, $iSize
Global $hStream, $tStruct, $pStruct, $iPos, $iLength = 0

_BASS_STARTUP()
___Debug(@error, "load bass.dll")

_BASS_Init($BASS_DEVICE_SPEAKERS, -1, 44100, 0, "")
___Debug(@error, "bass init")

$hStream = _BASS_StreamCreate(44100, 1, 0, $STREAMPROC_PUSH, 0)
___Debug(@error, "create push stream")

_BASS_ChannelPlay($hStream, 1)
___Debug(@error, "start stream")

$hPid = Run("CenterCutCl stereo.wav -c stdout", @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
While 1
    $bStdout = StdoutRead($hPid, 0, 1)
    If @error Then ExitLoop
    $iSize = BinaryLen($bStdout)
    If Not $iSize Then ContinueLoop
    ___DeBug(@error, "binarylen of stdout: " & $iSize)

    $iLength += $iSize

    $tStruct = DllStructCreate("byte[" & $iSize & "]")
    DllStructSetData($tStruct, 1, $bStdout)

    _BASS_StreamPutData($hStream, DllStructGetPtr($tStruct), DllStructGetSize($tStruct))
    ___DeBug(@error, "streamputdata")
    $tStruct = 0
WEnd

While _BASS_ChannelIsActive($hStream)
    $iPos = _BASS_ChannelGetPosition($hStream, $BASS_POS_BYTE)
    If $iPos >= $iLength Then ExitLoop
    Sleep(20)
WEnd


_Exit()

Func _Exit()
    _BASS_StreamFree($hStream)
    ___Debug(@error, "free stream")

    _BASS_Free()
    ___Debug(@error, "free bass")

    Exit
EndFunc   ;==>_Exit




Func ___DeBug($iError, $sAction)
    Switch $iError
        Case -1
            ConsoleWrite(@CRLF & "-" & $sAction & @CRLF)
        Case 0
            ConsoleWrite(@CRLF & "+" & $sAction & " - OK" & @CRLF)
        Case Else
            ConsoleWrite(@CRLF & "!" & $sAction & " - FAILED" & @CRLF)
            Exit
    EndSwitch
EndFunc   ;==>___DeBug
Edited by eukalyptus
Posted (edited)

Thanks ProgAndy.

...Or use the flag $BASS_MIXER_DOWNMIX

$hMixer = _BASS_Mixer_StreamCreate($rate,1, BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE)) 

$hChannel = _BASS_Mixer_StreamAddChannel($hMixer, $hStream, $BASS_MIXER_DOWNMIX)

...

Using this method, the result seems satisfactory. Should I try another set. thanks

Edited by nico18n
Posted

Thanks E,

I can't wait to get home from work to test your script out. This is fantastic!! So you are telling me that I can use SoX to create the LFE (it does stdout)?. Man, that would be awesome!! This is more than I could hope for. I've got some real fun ahead.

You are a genius :mellow: and a really super guy for putting up with a dumb, old dude like me. :P

Thanks,

Joe

Are you experienced?

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
  • Recently Browsing   0 members

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