Results 1 to 7 of 7

Thread: Playing sound/music in TB besides TBASS

  1. #1

    Playing sound/music in TB besides TBASS

    Hi there, is there any other audio library available for TB besides TBASS that can play sound files(wav, or ogg)?

    As much as I like TBASS, I don't agree with it's license.
    Unless if it's different from the real BASS library.

    winmm is one option that I found on this message boards however.. does it support multiple channels like TBASS?




  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Hi poceduo and welcome to thinBasic community.

    TBASS module is a wrapper of original BASS library. I have authorization from Ian Luck (un4seen) to use BASS library as far as scripts created with thinBasic using TBASS are non commercial.
    You can use TBASS as far as you create free scripts. If you create commercial scripts you need to buy a BASS licence. See thinBasic help at http://www.thinbasic.com/public/prod...html/tbass.htm

    I do not know if winmm is an option for multiple channels, also considering it is an old API.
    Maybe someone else can suggest something on this matter.
    If there are other libraries we can consider, we can think about it.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159
    OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications.

    The library models a collection of audio sources moving in a 3D space that are heard by a single listener somewhere in that space. The basic OpenAL objects are a Listener, a Source, and a Buffer. There can be a large number of Buffers, which contain audio data. Each buffer can be attached to one or more Sources, which represent points in 3D space which are emitting audio. There is always one Listener object (per audio context), which represents the position where the sources are heard -- rendering is done from the perspective of the Listener.
    I dont have time at the moment but this could be another option.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    It depends what level of functionality you need.

    If you need 3D sound, I guess the OpenAL recommended by Mike could be an option. As ThinBASIC can access functions from DLLs, you would just create DECLARE statements and then you can use it.

    If you need just to play some (even multiple) sounds, manipulate their volume and do other basic (non-3D) stuff, you can try MCI commands:
    #MINVERSION 1.8.8.0
    
    String mySoundFile = APP_SourcePath + "prodigy.wav"
    
    ' -- To be able to use mciSendString, we need to decalre it first
    Declare Function mciSendString Lib "WINMM.DLL" Alias "mciSendStringA" ( ByRef lpstrCommand      As Asciiz, 
                                                                            ByRef lpstrReturnString As Asciiz, 
                                                                            ByVal uReturnLength     As DWord , 
                                                                            ByVal hwndCallback      As DWord ) As DWord
                                                                            
    ' -- Open file (WAV, MP3) and give it alias for easier manipulation                                                                         
    mciSendString("open "+mySoundFile+" alias mySound", "", 0, 0)      
    
    ' -- Start playing the file
    mciSendString("play mySound"                      , "", 0, 0)                                                                                                                                                
    
    ' -- Give it second to play
    Sleep 1000                 
    
    ' -- Release the file
    mciSendString("close mySound"                      , "", 0, 0)
    


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #5

    How to play single note tones (not sound files)

    Ive been looking in thinBasic documentation and forum for ability to play simple sounds.


    The above mentioned solutions (BASS, OpenAL, MCI) seem to be focussed on sound files.
    That is not what I want.

    Some old BASIC's (GW, BBC, PET) used to have a simple native function like this:-
    SOUND (frequency,duration).
    With this we can compose a simple melody by issuing a series of SOUND commands.
    This is what I seek.

    Has progress of technology killed such simple capability?
    (vorsprung durch technik I suppose
    http://www.thinbasic.com/community/i...omputer012.gif ).

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Steve,

    I remember this functionality from DOS BASIC dialects. The problem is that not every PC now has the PC Speaker, which was used to generate the sound itself.

    The Windows API contains the function to play on speaker, here minimal test in ThinBASIC, but as my PC does not have PC Speaker device, I cannot verify if it works:
    ' -- Win32 API function to play on speaker
    Declare Function WinBeep Lib "KERNEL32.DLL" Alias "Beep" ( ByVal dwFreq As DWord, ByVal dwDuration As DWord ) As Long                                              ' BOOL
    
    ' -- Call the function, 750Hz, 300ms
    WinBeep( 750, 300 )
    
    Also, as the documentation says:
    Eventually because of the lack of hardware to communicate with, support for Beep was dropped in Windows Vista and Windows XP 64-Bit Edition.
    I think the solution could be to generate WAV file programatically, and play it via soundcard device.


    Petr
    Last edited by Petr Schreiber; 07-03-2012 at 13:08.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  7. #7

    Thumbs up WinBeep does the job

    Thanks Petr

    WinBeep does the job for me on my ancient rig (Pentium 4, WinXP/sp0)


    It is a pity WinBeep is not available in newer Windows.
    Attached Files Attached Files

Similar Threads

  1. Cat Playing with Dolphins
    By Charles Pegge in forum Shout Box Area
    Replies: 1
    Last Post: 12-04-2011, 21:41

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •