nullschritt Posted July 30, 2014 Posted July 30, 2014 So I've been working on an instant messenger in my spare time and im trying to implement audio streaming. I previously had code to send/receive the data, currently I only have the script which sends the data, but I cant remember how to play it back. Here's what I have. if $cmdlineraw = "/audiosrv" Then _BASS_Startup() _BASS_ENCODE_Startup() _BASS_EXT_STARTUP() _BASS_RecordInit(-1) $hRecord = _BASS_RecordStart(44100, 2, 0, $BASS_EXT_RecordProc) $aBuffer = _BASS_EXT_MemoryBufferCreate() $hEncoder = _BASS_Encode_Start($hRecord, '"' & @ScriptDir & '\lame" -r -x -b64 -h - -', 0, $BASS_EXT_EncodeProc, $aBuffer[0]) while 1 if $audioenabled = 1 Then _checkstdinaudio() iSize = _BASS_EXT_MemoryBufferGetSize($aBuffer) If $iSize Then $bMp3Data = _BASS_EXT_MemoryBufferGetData($aBuffer, $iSize) ;send data to main process EndIf EndIf sleep(25) WEnd EndIf
wakillon Posted August 21, 2014 Posted August 21, 2014 @eukalyptus I came across your examples folder in the last UDF (in which I confess I had not looked at it yet!) and I found them very interesting. Particularly _BASS_EXT_Generator.au3 file where the Tetris song with effects added, is so melodious ! Bravo the artist! Danke sehr ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
wakillon Posted August 26, 2014 Posted August 26, 2014 (edited) OK I’m not a scripter, merely a rare part time hobbyist because of the hours I work, but as I’m off work at the moment with a broken leg I was asked by one of my sons if it was possible to create an equalizer and/or audio effects with Autoit. So being a little familiar with the bass udf I came up the example below. Some of the effects are copied from the examples provided by eucalyptus so many thanks to him because it pointed me in the right direction to create more. Obviously you need at least bass.dll, bass and bass_FX.dll Please give it a try and offer suggestions for improvement. Nice example and great effects ! Just a little precisiion on one of your comments in the script : basswma.dll can not be used for play m4a. The AAC/MP4 (also m4a) format is supported as standard by BASS.dll via the OS's codecs since windows Vista. Only Windows XP need bass_aac.dll for play them. Thanks. Suggestion : You can use _Bass_PluginFree in your OnAutoItExit function. Edited August 26, 2014 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
bolthead Posted August 26, 2014 Posted August 26, 2014 Thank you for looking and your comments Just a little precisiion on one of your comments in the script : basswma.dll can not be used for play m4a. The AAC/MP4 (also m4a) format is supported as standard by BASS.dll via the OS's codecs since windows Vista. Only Windows XP need bass_aac.dll for play them. Thanks for the correction – one day I’ll read rather than skim the docs. I'll sort it out Suggestion : You can use _Bass_PluginFree in your OnAutoItExit function. I’m not sure if that is necessary as _BASS_Free() ‘Frees all resources’ according to UDF. But I suppose it never hurts to be doubly safe. Thanks again
bolthead Posted August 26, 2014 Posted August 26, 2014 While looking for a file that I needed to edit I remembered this example that I made to crossfade 2 tracks. The ‘File Open’ dialog will open twice so as you get the 2 tracks, it will then play the last 35 seconds of the first track and after 10 seconds fade in the second track and fade out the first. You will find that some tracks have a different amount of silence at the beginning and end so you will need to adjust some values to suit your preference. Crossfade.au3 coffeeturtle 1
wakillon Posted August 30, 2014 Posted August 30, 2014 I’m not sure if that is necessary as _BASS_Free() ‘Frees all resources’ according to UDF. But I suppose it never hurts to be doubly safe. Thanks again Look at Bass_udf of EUKALYPTUS There is a _BASS_PluginFree.au3 file in the examples folder, and the _Bass_PluginFree function is used before _BASS_Free. May be a detail but this function has to have her utility... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
kaz Posted August 30, 2014 Posted August 30, 2014 Is it possible to play a xm file in loop? I try function _BASS_MusicLoad with $BASS_SAMPLE_LOOP flag, my file is playing only one time. At the end, i try to set the position to 0 but i obtained an error.
wakillon Posted August 30, 2014 Posted August 30, 2014 Is it possible to play a xm file in loop? I try function _BASS_MusicLoad with $BASS_SAMPLE_LOOP flag, my file is playing only one time. At the end, i try to set the position to 0 but i obtained an error. Try this expandcollapse popup#include <Bass.au3> HotKeySet ( '{ESC}', '_Exit' ) $sXmFilePath = '3213415.xm' _Bass_STARTUP ( 'Bass.dll' ) _DeBug ( @error, '_Bass_STARTUP' ) _Bass_Init ( 0, -1, 44100, 0, '' ) _DeBug ( @error, '_Bass_Init' ) $hMusic = _BASS_MusicLoad ( 0, $sXmFilePath, 0, 0, $BASS_SAMPLE_LOOP, 0 ) _DeBug ( @error, '_BASS_MusicLoad' ) _BASS_ChannelPlay ( $hMusic, False ) _DeBug ( @error, '_BASS_ChannelPlay' ) While 1 Sleep ( 500 ) WEnd 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, error : ' & $iError & @CRLF ) Exit EndSwitch EndFunc ;==> _DeBug () Func _Exit () _BASS_Free() Exit EndFunc ;==> _Exit () AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
kaz Posted August 30, 2014 Posted August 30, 2014 Thank you for the code but it isn't ok with my file. Perhaps, my xm file isn't ok. I post it. you have to rename it with xm at the end. Sample.au3
wakillon Posted August 30, 2014 Posted August 30, 2014 Yes, your xm file stop after 63 sec and there is a fade effect at the end. Did you create it with FastTracker ? Another way to play XM : >XM Player by trancexx AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
kaz Posted August 30, 2014 Posted August 30, 2014 i downloaded it. The fade effect didn't appear with VLC, how long is it? and after the the music should start again? I will try the other way.
wakillon Posted August 31, 2014 Posted August 31, 2014 (edited) Searching for xm format, it appears that xm can be set without loop. So for this kind of file, try like this expandcollapse popup#include <Bass.au3> HotKeySet ( '{ESC}', '_Exit' ) $sXmFilePath = 'Sample.xm' _Bass_STARTUP ( 'Bass.dll' ) _DeBug ( @error, '_Bass_STARTUP' ) _Bass_Init ( 0, -1, 44100, 0, '' ) _DeBug ( @error, '_Bass_Init' ) Global $hMusic = _BASS_MusicLoad ( 0, $sXmFilePath, 0, 0, BitOR ( $BASS_MUSIC_LOOP, $BASS_MUSIC_FT2MOD, $BASS_MUSIC_PRESCAN ), 0 ) _DeBug ( @error, '_BASS_MusicLoad' ) $iBytesLength = _Bass_ChannelGetLength ( $hMusic, $BASS_POS_BYTE ) _DeBug ( @error, '_Bass_ChannelGetLength' ) $hSync = _Bass_ChannelSetSync ( $hMusic, $BASS_SYNC_POS, $iBytesLength, '_Bass_SyncProc', 0 ) _DeBug ( @error, '_Bass_ChannelSetSync' ) _BASS_ChannelPlay ( $hMusic, False ) _DeBug ( @error, '_BASS_ChannelPlay' ) While 1 Sleep ( 500 ) WEnd 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, error : ' & $iError & @CRLF ) Exit EndSwitch EndFunc ;==> _DeBug () Func _Bass_SyncProc ( $handle, $channel, $data, $user ) ConsoleWrite ( @Crlf & '! End Song Reached' & @CRLF ) _BASS_ChannelPlay ( $channel, True ) _DeBug ( @error, '_BASS_ChannelPlay' ) EndFunc ;==> _Bass_SyncProc () Func _Exit () _BASS_Free() Exit EndFunc ;==> _Exit () Edited August 31, 2014 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
kaz Posted August 31, 2014 Posted August 31, 2014 Thank you again. I take your script and obtain an error on the _Bass_ChannelSetSync function. I search for an other bass.au3 and take it from http://www.autoit.de/index.php?page=Thread&threadID=26550 I don't know if it is the last udf. the one on the first post is an old one. At this time, the song want to start again but only four or five notes. i look in the new au3 at the _Bass_ChannelSetSync and change the $type parameter : before $BASS_SYNC_POS, now $BASS_SYNC_MIXTIME. And now everything is ok, the "music" is played for ten minutes... Thank you for your help ;-)))
wakillon Posted August 31, 2014 Posted August 31, 2014 Yes it's the last Bass UDF to use. $BASS_SYNC_POS is the good constant as there is no mix in script. Did you place the new Bass.dll in the same folder of your script ? Also, try with _BASS_ChannelStop ( $channel ) before _BASS_ChannelPlay ( $channel, True ) in the _Bass_SyncProc Function. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
kaz Posted August 31, 2014 Posted August 31, 2014 It's ok with $type as $BASS_SYNC_POS and _BASS_ChannelStop ( $channel ) before _BASS_ChannelPlay ( $channel, True ) in the _Bass_SyncProc Function. Thanks again.
LondonNDIB Posted January 20, 2015 Posted January 20, 2015 I'm a little out of my element here. Can someone tell me IF this UDF is what I might need to explore to >answer this post? To save you following the link: basically, I want some method for knowing if a sound is currently playing. Any sound. I just want to know if the speakers are currently making a sound (by way of program, not my ears).
Belini Posted April 7, 2015 Posted April 7, 2015 (edited) I wanted to understand why when I use # AutoIt3Wrapper_Run_Obfuscator = y I get error messages in functions DllCallbackRegister(), Eval() and Assign() Script de test: #AutoIt3Wrapper_Run_Obfuscator=y #include <Misc.au3> #include "BassConstants.au3" #include "Bass.au3" _BASS_STARTUP(@ScriptDir & "\bass.dll") _BASS_Init(0, -1, 44100, 0, "") $sound = _BASS_StreamCreateFile(False, @ScriptDir & "\sound.wav", 0, 0, 0) _BASS_ChannelPlay($sound, 0) Sleep(3000) _BASS_ChannelStop($sound) Exit Errors messages: expandcollapse popup-### Obfuscation Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_StreamCreate D:\test_Obfuscator\Bass.au3(2100,1) Warning for line:$proc_s = DllCallbackRegister($proc, "ptr", "dword;ptr;dword;ptr") -### Obfuscation Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_StreamCreateURL D:\test_Obfuscator\Bass.au3(2296,1) Warning for line:$dcProc = DllCallbackRegister($proc, "ptr", "ptr;dword;ptr;") -### Obfuscation Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_StreamCreateFileUser D:\test_Obfuscator\Bass.au3(2449,1) Warning for line:$proc_s = DllCallbackRegister($proc, "ptr", "ptr;ptr;ptr;ptr") -### Obfuscation Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_RecordStart D:\test_Obfuscator\Bass.au3(2862,1) Warning for line:$dcProc = DllCallbackRegister($proc, "int", "dword;ptr;dword;ptr;") -### Obfuscation Error: Found Eval() statement using unsolvable Variable, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_ChannelSetFX D:\test_Obfuscator\Bass.au3(4032,1) Warning for line:Local $BASS_ret_ = DllCall($_ghBassDll, "dword", "BASS_ChannelSetFX", "DWORD", $handle, "DWORD", Eval($type & "_Value"), "int", $priority) -###2 Obfuscation Error: Found Assign() statement which will lead to problems running your obfuscated script. >### current Func: _BASS_ChannelSetFX D:\test_Obfuscator\Bass.au3(4036,1) Warning for line:Assign("BASS_FX_" & $BASS_ret_[0], Eval(StringReplace($type, "_FX", "")), 2) -### Obfuscation Error: Found Eval() statement using unsolvable Variable, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_FXSetParameters D:\test_Obfuscator\Bass.au3(4110,1) Warning for line:$struct = DllStructCreate(Eval("BASS_FX_" & $fxhandle)) -### Obfuscation Error: Found Eval() statement using unsolvable Variable, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_FXGetParameters D:\test_Obfuscator\Bass.au3(4140,1) Warning for line:Local $sRet = DllStructCreate(Eval("BASS_FX_" & $fxhandle)) -### Obfuscation Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_ChannelSetDSP D:\test_Obfuscator\Bass.au3(4175,1) Warning for line:$proc_s = DllCallbackRegister($proc, "ptr", "dword;dword;ptr;dword;ptr") -### Obfuscation Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to problems running your obfuscated script. >### current Func: _BASS_ChannelSetSync D:\test_Obfuscator\Bass.au3(4312,1) Warning for line:$proc_s = DllCallbackRegister($proc, "ptr", "dword;dword;dword;ptr") -############################################################################################# -#### Obfuscator Found 10 Error(s)!!!! This means your script could have problems running properly. #### -############################################################################################# +> Obfuscator v1.0.30.1 finished obfuscating 2452 lines, stripped 6727 comment lines. created:D:\test_Obfuscator\Test_Obfuscated.au3 Files to test: https://www.dropbox.com/s/mciswiktph7f1mt/test_Obfuscator.rar?dl=0 Edited April 7, 2015 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
BrewManNH Posted April 7, 2015 Posted April 7, 2015 Because the Obfuscator can't handle those functions, just as the error message explain, so it may strip out the variables or functions you're trying to use. Seeing as how there's no reason to run the obfuscator on your script, you can always disable it. Also, later versions of AutoIt have gotten rid of the Obfuscator program and replaced it with Au3Stripper, mainly because the obfuscation didn't really protect your script. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Belini Posted April 7, 2015 Posted April 7, 2015 Because the Obfuscator can't handle those functions Even with these error messages the script works properly once compiled, these functions they are ignored when making the obfuscation? you can always disable it. Also, later versions of AutoIt have gotten rid of the Obfuscator program Yes I know that the newer version does not have the Obfuscator and I using the older version just for this reason. mainly because the obfuscation didn't really protect your script. Yes really obfuscation does not protect script is more difficult to understand the code if someone decompile the executable. My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
BrewManNH Posted April 7, 2015 Posted April 7, 2015 Well, if you insist on using the Obfuscator, you will have to deal with it's limitations as well. If you're not using the functions those warnings are coming from, then you won't have to worry about them. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now