 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
k3ph
Joined: 20 Jul 2006 Posts: 223
|
Posted: Sat Oct 25, 2008 11:55 am Post subject: BASS Library - extreme AHK multimedia power! |
|
|
[ description ]
BASS for powerful extensible AHK multimedia >:D !
It gives AHK power to play on-the-fly soundfiles, stream, recording, mixing, adding effects using EAX, DX8 etc everything in a tiny 96KB dll.
BASS can be extended with plugins, supporting many sound format. It can load VST and Winamp plugins for effects DSP, read ID3v1, ID3v2.2/3/4,OGG/FLAC, WMA, APE, OFR, MPC, AAC tags etc. And even video playback!
BASS Streamable built-in (*.mp3;*.mp2;*.mp1;*.ogg;*.oga;*.wav;*.aif;*.aiff;*.aifc;)
BASS Modules built-in (*.mo3;*.xm;*.mod;*.s3m;*.it;*.mtm;*.umx;)
CD Audio (*.cda;)
Free Lossless Audio Codec (*.flac;)
MIDI (*.midi;*.mid;*.mus;*.rmi;*.kar;)
Windows Media Audio (*.wma;*.wmv;*.wmp;*.asf;)
AAC (*.aac;*.mp4;*.m4a;*.m4b;*.m4p;)
WavPack Audio Codec (*.wv;*.wvc;)
Monkey's Audio (*.ape;)
MusePack (*.mpc;*.mpp;*.mp+;)
Dolby Digital (*.ac3;)
Apple Lossless (*.mp4;*.m4a;*.m4b;*.m4p;)
Speex (*.spx;*.wav;*.oga;*.ogg;)
The True Audio (*.tta;)
OptimFROG (*.ofr;)
Video (*.avi;*.mkv;*.mp4;*.wmv;*.mpeg;*.mpg;)
*The list refers to the supported fileformats with BASS and its native plugins
**Video supported filetypes are still being listed, also its video codecs handling.
___
[ information ]
- Official WebSite of BASS Lib
- BASS code developer WebSite
___
[ related projects ]
- Trout Player _________________ [ profile | ahk.net | ahk.talk ]
Last edited by k3ph on Thu Sep 08, 2011 3:41 am; edited 22 times in total |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 747 Location: Texas, USA
|
Posted: Sat Oct 25, 2008 1:32 pm Post subject: Re: BASS Library - extend AHK sound play capabilities |
|
|
Looks useful. Thanks for sharing.
| k3ph wrote: | -BASS Library is _f_huge, it has many features. Currently I've wrapped 25% of it (going to release as revision 1), please wait.
|
I look forward to to the final version. Keep us informed. |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Sat Oct 25, 2008 6:16 pm Post subject: |
|
|
Very nice!
Screamer Radio uses the BASS library too... |
|
| Back to top |
|
 |
Ice_Tea
Joined: 12 Jan 2008 Posts: 131
|
Posted: Sun Oct 26, 2008 1:27 am Post subject: |
|
|
(Was this thread deleted or something iirc I replied to this :S)
Hmm, shouldn't there be a way to keep the DLL within the memory at all times, so that you don't have to write it to the HDD? |
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 223
|
Posted: Sun Oct 26, 2008 1:30 am Post subject: |
|
|
| Ice_Tea wrote: | (Was this thread deleted or something iirc I replied to this :S)
Hmm, shouldn't there be a way to keep the DLL within the memory at all times, so that you don't have to write it to the HDD? |
You are probably confusing this thread with the BASSMOD Library
Yes it would be a nice idea to wrap the DLL, but you don't need to write, just download it once. _________________ [ profile | ahk.net | ahk.talk ] |
|
| Back to top |
|
 |
Ice_Tea
Joined: 12 Jan 2008 Posts: 131
|
Posted: Sun Oct 26, 2008 2:30 am Post subject: |
|
|
| k3ph wrote: | You are probably confusing this thread with the BASSMOD Library
Yes it would be a nice idea to wrap the DLL, but you don't need to write, just download it once. |
Oh, lulz, keke. yeah, dw using a external dll isn't such a big deal... |
|
| Back to top |
|
 |
:( Guest
|
Posted: Sun Oct 26, 2008 2:34 am Post subject: |
|
|
| Ice_Tea wrote: | | k3ph wrote: | You are probably confusing this thread with the BASSMOD Library
Yes it would be a nice idea to wrap the DLL, but you don't need to write, just download it once. |
Oh, lulz, keke. yeah, dw using a external dll isn't such a big deal... |
what is not big deal? many sound players uses bass as core. |
|
| Back to top |
|
 |
Ice_Tea
Joined: 12 Jan 2008 Posts: 131
|
Posted: Sun Oct 26, 2008 3:15 am Post subject: |
|
|
wrote: | | what is not big deal? many sound players uses bass as core. |
Bah, didn't feel like pressuring him into doing it... |
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 223
|
Posted: Fri Nov 07, 2008 12:01 pm Post subject: |
|
|
I'm proud to announce the BASS Library reach production-ready stage. Most of the functions were checked and now AHK developers can enjoy the power of BASS.
Notes: the SVN is current down and more examples coming soon for the non-basic functions test. Stay in BASS tune! _________________ [ profile | ahk.net | ahk.talk ] |
|
| Back to top |
|
 |
WankaUSR
Joined: 14 Aug 2007 Posts: 86
|
Posted: Fri Nov 07, 2008 8:28 pm Post subject: |
|
|
i need some help. I'm trying to use bass_aac.dll after BASS_Init()
| Code: | dll=bass_aac.dll
BASS_%dll%_Init() |
I have tried using only aac and bass_aac as the dll var but it doesn't recognize the stream. what am I doing wrong? |
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 223
|
Posted: Mon Nov 10, 2008 5:09 pm Post subject: |
|
|
| WankaUSR wrote: | i need some help. I'm trying to use bass_aac.dll after BASS_Init()
| Code: | dll=bass_aac.dll
BASS_%dll%_Init() |
I have tried using only aac and bass_aac as the dll var but it doesn't recognize the stream. what am I doing wrong? |
Please pay attention before posting: in the moment you posted your question, bassaac.ahk wasn't released yet and wasn't supported.
Note you don't need to #include plugin libraries anymore. All you need to do is to call bass.ahk
From example3:
| Code: | /*
BASS Library - Stream GUI (AAC Only) Example
by k3ph
required files: bass.dll, bass_aac.dll, bass.ahk, bassaac.ahk
if apple lossless is required, add: bass_alac.dll, bassalac.ahk and dont forget to call BASS_ALAC_Init() and free it with BASS_ALAC_Free()
*/
#NoEnv
#SingleInstance Force
#Persistent
Critical,On
onexit, exit
; include bass :)
#Include bass.ahk
; load bass :)
BASS_Load()
; you can load anything, anytime
BASS_Init(-1,44100,0,0,0)
BASS_AAC_Init()
; gui things
PM_gui = 1
PM_ControlID = own
PM_widthInSegments = 200
PM_height = 100
PM_color = green
PM_bgcolor = gray
PM_xpos = 0
PM_ypos = 0
Add_ProgressMeter(PM_gui, PM_ControlID, PM_widthInSegments, PM_height, PM_color, PM_bgcolor, PM_xpos, PM_ypos)
SetTimer, showstream, 250
gosub visualstream
gosub openstream
; some hotkeys
#IfWinActive Stream GUI
r::gosub reverb
c::gosub chorus
^c::gosub compressor
p::gosub parameq
d::gosub distortion
e::gosub echo
f::gosub flanger
g::gosub gargle
i::gosub i3dl2reverb
o::gosub openstream
!F4::gosub exit
^F4::reload
#IfWinActive
return
reverb:
;BASS_FXSetParameters(BASS_FX_DX8_REVERB,0.001)
BASS_ChannelSetFX(stream,BASS_FX_DX8_REVERB,0)
return
chorus:
BASS_ChannelSetFX(stream,BASS_FX_DX8_CHORUS,0)
return
compressor:
BASS_ChannelSetFX(stream,BASS_FX_DX8_COMPRESSOR,0)
return
distortion:
BASS_ChannelSetFX(stream,BASS_FX_DX8_DISTORTION,0)
return
echo:
BASS_ChannelSetFX(stream,BASS_FX_DX8_ECHO,0)
return
flanger:
BASS_ChannelSetFX(stream,BASS_FX_DX8_FLANGER,0)
return
gargle:
BASS_ChannelSetFX(stream,BASS_FX_DX8_GARGLE,0)
return
i3dl2reverb:
BASS_ChannelSetFX(stream,BASS_FX_DX8_I3DL2REVERB,0)
return
parameq:
BASS_ChannelSetFX(stream,BASS_FX_DX8_PARAMEQ,0)
return
openstream:
BASS_ChannelStop(stream)
fileselectfile, file, 1, , select a song,(*.mp3;*.mp2;*.mp1;*.ogg;*.oga;*.wav;*.aiff;*.aac;*.mp4;*.m4a)
if file =
traytip, , please select a file
else
bass=bass.dll
stream:=BASS_StreamCreateFile(false,file,0,0,4)
BASS_ChannelPlay(stream,0)
return
visualstream:
Gui, %PM_gui%:+AlwaysOnTop +Owner
Gui, %PM_gui%:Show, NoActivate, Stream GUI
return
showstream:
kchannellevel := 10000000*2.5
channellevel := BASS_ChannelGetLevel( stream )
if (channellevel = "-1")
level2progress = 0
level2progress := abs(channellevel) / kchannellevel
Update_ProgressMeter(PM_gui, PM_ControlID, level2progress)
return
/*
zed gecko's gui code
Add_ProgressMeter adds a "progress-meter" Control to a Gui.
It can only be used on a Gui with a number (like Gui, 1: or Gui, 99:)but not on a unnumbered Gui.
The generated control can disply the fluctuation of value in a range from 0 - 100.
Usage : Add_ProgressMeter(PM_gui, PM_ControlID, PM_widthInSegments, PM_height, PM_color, PM_bgcolor, PM_xpos, PM_ypos)
PM_gui = the number of the Gui
PM_ControlID = the name of the progress meter control. Use the same name with the "Update_ProgressMeter"-function
PM_widthInSegments = the width of the control in segments. (Each segment is of 2 pixel width)
PM_height = the height of the control in pixel
PM_color = the color of the progress-meter
PM_bgcolor = the background-color of the progress-meter
PM_xpos = the X-position of the controls top-left corner
PM_ypos = the Y-position of the controls top-left corner
(if the X and Y position are both omited or set to 0, the control uses automatic positioning)
*/
Add_ProgressMeter(PM_gui, PM_ControlID, PM_widthInSegments, PM_height, PM_color, PM_bgcolor, PM_xpos = 0, PM_ypos = 0)
{
global
PM_segmentspace = 2 ;this is the visible size of on segment in pixel
PM_segmentsize := (PM_segmentspace + 1)
PM_widthInSegments += -1
%PM_ControlID%_Segments := PM_widthInSegments
if (PM_xpos = 0 AND PM_ypos = 0)
{
Gui, %PM_gui%:Add, Progress, v%PM_ControlID%0 w%PM_segmentsize% h%PM_height% c%PM_color% Background%PM_bgcolor% Vertical,
}
else
{
Gui, %PM_gui%:Add, Progress, v%PM_ControlID%0 w%PM_segmentsize% h%PM_height% x%PM_xpos% y%PM_ypos% c%PM_color% Background%PM_bgcolor% Vertical,
}
Loop, %PM_widthInSegments%
{
Gui, %PM_gui%:Add, Progress, v%PM_ControlID%%A_Index% w%PM_segmentsize% h%PM_height% xp+%PM_segmentspace% c%PM_color% Background%PM_bgcolor% Vertical,
}
}
/*
Update_ProgressMeter puts new contents in the progress-meter control created by Add_ProgressMeter.
Usage: Update_ProgressMeter(PM_gui, PM_ControlID, PM_NewContent)
PM_gui = the number of the Gui the control is located in.
PM_ControlID = the name of the progress meter control. Use the name that was used in the "Add_ProgressMeter"-function
PM_NewContent = the new content of the control. it must be a number between 0 and 100.
the new content will be displayed in the most-right segment.
*/
Update_ProgressMeter(PM_gui, PM_ControlID, PM_NewContent = 0)
{
PM_oldSegments := %PM_ControlID%_Segments
Loop, %PM_oldSegments%
{
PM_NewSegment := A_Index - 1
GuiControlGet, PM_Transfervar, %PM_gui%:, %PM_ControlID%%A_Index%
GuiControl,%PM_gui%:, %PM_ControlID%%PM_NewSegment%, %PM_Transfervar%
}
GuiControl,%PM_gui%:, %PM_ControlID%%PM_oldSegments%, %PM_NewContent%
}
return
guiclose1:
guiescape:
guiclose:
goto exit
return
exit:
; stops the stream
BASS_ChannelStop(stream)
; flushes what was loaded before
BASS_AAC_Free()
BASS_Free()
ExitApp |
(note that apple lossless m4a isnt supported by the bass_aac but its supported by bass_alac !)
Enjoy! _________________ [ profile | ahk.net | ahk.talk ] |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7279 Location: Australia
|
Posted: Sat Nov 22, 2008 1:08 pm Post subject: |
|
|
k3ph, in the comments you've pointed out that BASS_ChannelGetTags returns a series of null-terminated strings for some tag types - however, the script function BASS_ChannelGetTags returns only the first null-terminated string. I suggest adding an optional parameter to override the return type, allowing a script to interpret the result as appropriate. For example,
| Code: | BASS_ChannelGetTags(handle,tags,return_type="Str"){
global
Return DllCall(BASS_DLLPATH . BASS_DLL . "\BASS_ChannelGetTags", UInt, handle, UInt, tags, return_type)
}
BASS_ChannelGetTags_List(handle,tags,delim){
ptr := BASS_ChannelGetTags(handle,tags,"Int")
Loop {
item := DllCall("MulDiv", Int, ptr, Int, 1, Int, 1, Str)
if item =
break
list .= item delim
ptr += StrLen(item) + 1
}
return SubStr(list,1,-StrLen(delim))
} | Below are examples of usage and output.
| Code: | MsgBox % BASS_ChannelGetTags( hStream, BASS_TAG_HTTP )
/*
HTTP/1.0 200 OK
*/
MsgBox % BASS_ChannelGetTags_List( hStream, BASS_TAG_HTTP, "`n" )
/*
HTTP/1.0 200 OK
Content-Type: audio/mpeg
icy-br:192
ice-audio-info: ice-samplerate=44100;ice-bitrate=192;ice-channels=2
icy-br:192
icy-description:This is my server description
icy-genre:Rock
icy-name:This is my server name
icy-private:0
icy-pub:1
icy-url:http://www.oddsock.org
Server: Icecast 2.3.2
Cache-Control: no-cache
icy-metaint:16000
*/ |
Also a warning about bass.dll callbacks: they are typically called by a worker thread. Even if no other thread is executing script, it is not guaranteed to work correctly. If the callback is too slow or calls a command that checks for messages, the thread may deadlock. Placing Critical N (where the callback will not run for N ms) on the first line of the callback function is a partial solution.
A proper solution would be to use a DLL or machine code to "route" the call to the proper thread.
(I've been helping Skwire with callbacks set via BASS_StreamCreateURL and BASS_ChannelSetSync.) |
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 223
|
Posted: Sat Nov 22, 2008 3:29 pm Post subject: |
|
|
I was going to ask you about these callbacks but i hadn't time to chat properly with you lately, ive been very busy D:
Thanks very much! I appreciate always your great help!
I still have some questions about callbacks and I hope I can be taught by you.
(Yes, I'm working with Skwire, I'm supporting fully his AHK Amp project :D)
___
Assimilated: BASS_ChannelGetTagsList - by Lexikos _________________ [ profile | ahk.net | ahk.talk ] |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7279 Location: Australia
|
Posted: Mon Dec 01, 2008 9:28 am Post subject: |
|
|
Found some more problems, this time in BASS_Free:
| Code: | BASS_Free(){
global
DllCall("FreeLibrary", UInt, BASS_DLLCALL)
Return DllCall(BASS_DLLPATH . BASS_DLL . "\BASS_Free", UInt, true)
} | Bass.dll should not be freed until after you call BASS_Free. If the DLL is actually freed, any structures, handles, pointers, etc. that BASS_Free uses will be gone.
BASS_Free does not accept any arguments. This was very easy to spot with DllCallDebugger() in use.
I believe the following works correctly:
| Code: | BASS_Free(){
global
return DllCall(BASS_DLLPATH . BASS_DLL . "\BASS_Free")
, DllCall("FreeLibrary", UInt, BASS_DLLCALL)
} | (Note the comma trick: FreeLibrary is called last, but the result of BASS_Free is returned.) |
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 223
|
Posted: Tue Dec 02, 2008 5:27 pm Post subject: |
|
|
i've noticed the unloading bass was very slow. thanks very much for fixing it, your dlcall debugger is awesome :D
i'm currently fixing all malformed functions and going to update it asap
i plan to finish the library asap. currently adding encode, mixing, synth and external plugins functions. _________________ [ profile | ahk.net | ahk.talk ] |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|