19 Jun '13 - 07:30 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1] 2 3 ... 12
  Reply  |  Print  
Author Topic: BASSWASAPI beta  (Read 75368 times)
Ian @ un4seen
Administrator
Posts: 15363


« on: 14 Apr '10 - 15:38 »
Reply with quoteQuote

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). WASAPI's regular and event-driven buffering systems are both supported.

   www.un4seen.com/stuff/basswasapi.zip (updated: 31 Jan '13)

32-bit and 64-bit versions are included. C/C++, Delphi, and Visual Basic APIs are provided (BASS.Net also includes support for it). Documentation is also included, so please see that for information on the various functions. Some examples are also included, but they're currently C/C++ only (RECTEST is available for VB); if anyone would like to port any of them to Delphi/VB, that would be handy Smiley

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. BASSmix 2.4.5 is required by the examples for the BASS_Mixer_ChannelGetPositionEx function, which is used to account for output latency when getting the position of a source channel.

This is not a final release, so things may change; feel free to make suggestions for changes/improvements/etc. Please also report any problems that you encounter.
« Last Edit: 19 Mar '13 - 17:21 by Ian @ un4seen » Logged
radio42
Posts: 4030


« Reply #1 on: 14 Apr '10 - 16:23 »
Reply with quoteQuote

The latest Bass.Net version fully supports the new WASAPI stuff.
It also includes (just like the BassAsioHandler) a BassWasapiHandler helper class, which takes care of almost anything.

Get it here: BASS.NET API
« Last Edit: 18 Jun '10 - 11:19 by radio42 » Logged
fmcoder
Posts: 387


« Reply #2 on: 16 Apr '10 - 16:32 »
Reply with quoteQuote

What we achieve using WASAPI instead of DirectSound?
Logged
radio42
Posts: 4030


« Reply #3 on: 16 Apr '10 - 16:46 »
Reply with quoteQuote

WASAPI (Windows Audio Session API) is the new audio standard introduced with Vista and WIndows 7.
It is a kind of replacement for DirectSound - which is not going to be further developed by Microsoft.
As such all new sound drivers of modern soundcards needs to support this new API.

WASAPI has a couple of benefits over DirectSound - the major benifit is low latency.
Depending on the quality of the driver of your soundcard you can get to the latency of ASIO.

There are a couple of other benefits, like session management, seperation of shared and exclusive mode, better driver and device management etc.

On Vista and Win7 DirectSound is also using WASAPI in the background, since now all audio stuff is going through WASAPI.
So using WASAPI directly is just more performent and uses less resources.
Logged
jeffdavis
Posts: 293


« Reply #4 on: 19 Apr '10 - 18:51 »
Reply with quoteQuote

Ian, this is FANTASTIC!   We've been waiting for this for 3 years!!!!!

Couple of intial observations.

The CHM doesn't seem to have any content?

Would be nice to seem some more examples?

Logged
Bert
Posts: 159


« Reply #5 on: 20 Apr '10 - 11:20 »
Reply with quoteQuote

Thank You Ian,
great improvement!
Do you plan to implement it directly to the bass.dll?
It would be easier for writing apps which should run on different Windows versions.

Bert
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #6 on: 20 Apr '10 - 17:17 »
Reply with quoteQuote

The CHM doesn't seem to have any content?

That's strange. Do you have the same problem with the other BASS/add-on documentation?

Actually, I vaguely recall seeing a previous thread about this issue (with the other CHM files). I don't remember the details, but I think it may have been a permissions issue and/or trying to open the documentation straight from the ZIP without extracting it first?

Would be nice to seem some more examples?

Yes, more will be added.

Do you plan to implement it directly to the bass.dll?
It would be easier for writing apps which should run on different Windows versions.

I'm not sure. There are no immediate plans for it, but I guess it might be incorporated into BASS.DLL at some point. BASSmix probably will be though, at which point an output plugin system would become more feasible, which would allow BASSWASAPI to be more integrated with BASS, if not built-in.

Note that BASSWASAPI.DLL will still load on older Windows, ie. there won't be any "This application has failed to start..." error messages, in case that is what you're concerned about Smiley
Logged
jeffdavis
Posts: 293


« Reply #7 on: 21 Apr '10 - 22:04 »
Reply with quoteQuote

That's strange. Do you have the same problem with the other BASS/add-on documentation?

Actually, I vaguely recall seeing a previous thread about this issue (with the other CHM files). I don't remember the details, but I think it may have been a permissions issue and/or trying to open the documentation straight from the ZIP without extracting it first?

My other CHM files from BASS all read fine.  This one displays the content on the left but the pane on the right is empty with a "Navigation to the webpage was canceld".   Also get a warning when opening this CHM saying it is an unknown publisher?

Nevermind.  Read another thread that said to click the unblock button in properties in Window 7.  Works fine now.

« Last Edit: 21 Apr '10 - 22:07 by jeffdavis » Logged
Bert B.
Posts: 103


« Reply #8 on: 22 Apr '10 - 07:42 »
Reply with quoteQuote

Quote
This one displays the content on the left but the pane on the right is empty with a "Navigation to the webpage was canceld".

You can find more information about that here:

http://www.helpandmanual.com/products_hhreg.html
Logged
ken
Posts: 630


« Reply #9 on: 26 Apr '10 - 10:20 »
Reply with quoteQuote

And here comes the Bass.Net (pre) version which supports the new WASAPI stuff.
It also includes (just like the BassAsioHandler) a BassWasapiHandler helper class, which takes care of almost anything.


Bernd,

I'm litle confused on how to use inputs with BassWasapiHandler.  I'm not sure how to add an input device. (I wanna use SetFullDuplex and add the input to a mixer, I do have several in/out on my soundcard [M-Audio Delta 1010])  It's bit different to AsioHandler. Also the documentation for "BassWasapiHandler Class" have a "Wasapi input" but I can't see that in code..

Next one..
 
How to list devices, I do like this, but get's doublles on the output devices.

BASS_WASAPI_DEVICEINFO info = new BASS_WASAPI_DEVICEINFO();

            for (int i = 0; BassWasapi.BASS_WASAPI_GetDeviceInfo(i, info); i++)
            {
               if(!info.IsInput)
                    cmbDevOut.Items.Add(info.ToString());

               if (info.SupportsRecording)
                   cmbDevIn.Items.Add(info.ToString());
            }




and last...

When usng BassWasapiHandler or BASS_WASAPI_DEVICEINFO, I get messagebox saying that I use version 0.0 and 1.0 was expected of Wasapi.

/Ken



Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #10 on: 26 Apr '10 - 13:07 »
Reply with quoteQuote

How to list devices, I do like this, but get's doublles on the output devices.

Those duplicates are probably the "loopback" devices, which capture the sound coming from the corresponding output devices. They can be identified by the BASS_DEVICE_LOOPBACK flag, but they don't currently have the BASS_DEVICE_INPUT flag set. Looking at the BASS_WASAPI_GetDeviceInfo documentation, it does mean that the example there is incomplete, as it is only checking for the BASS_DEVICE_INPUT flag and is overlooking BASS_DEVICE_LOOPBACK. So either that example (and BASS.Net I suspect) need updating or the BASS_DEVICE_INPUT flag needs to be added to the loopback devices. I think the latter is probably a slightly better solution, so an updated DLL is now in the package (see the 1st post).
Logged
radio42
Posts: 4030


« Reply #11 on: 27 Apr '10 - 10:29 »
Reply with quoteQuote

@Ken:

I am not sure about your issues, as here it works just fine, so maybe you should re-download from the above post.

Here is some code snippet for using the BassWaspiHandler (which works almost exactly like the BassAsioHandler):
private BassWasapiHandler _wasapiHandler = null;
private int _recordStream = 0;
private int _fullDuplexStream = 0;
...

_wasapiHandler = new BassWasapiHandler(deviceId, false, 48000, 2, 0f, 0f);
if (_wasapiHandler.Init())
{
    _recordStream = _wasapiHandler.InputChannel;

    // double check, that the device is not muted externally
    if (_wasapiHandler.DeviceMute)
        _wasapiHandler.DeviceMute = false;
    // check, that the master volume is not 0
    if (_wasapiHandler.DeviceVolume == 0f)
        _wasapiHandler.DeviceVolume = 1f;

    // start WASAPI
    _wasapiHandler.Start();
}
...

// create a full-duplex channel which might be added to an output mixer
_wasapiHandler.SetFullDuplex(0, BASSFlag.BASS_STREAM_DECODE, false);
_fullDuplexStream = _wasapiHandler.OutputChannel;
...

To get all available WASAPI recording devices you might use something like this:
BASS_WASAPI_DEVICEINFO[] wasapiDevices = BassWasapi.BASS_WASAPI_GetDeviceInfos();
for (int i = 0; i < wasapiDevices.Length; i++)
{
    try
    {
        if (!wasapiDevices[i].IsEnabled)
        {
            wasapiDevices[i].name = "ERROR N/A: " + wasapiDevices[i].name;
        }
        else
        {
            if (wasapiDevices[i].SupportsRecording)
            {
                // this is a recording device
            }
            else
            {
                // this is a playback device
            }
        }
    }
    catch { }
}
Logged
ivan
Posts: 2


« Reply #12 on: 29 Apr '10 - 18:38 »
Reply with quoteQuote

Hi Ian,

some small changes on basswasapi.pas. For info see *.pas file

regards

Ivan

* basswasapi.7z (1.35 KB - downloaded 36 times.)
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #13 on: 30 Apr '10 - 15:43 »
Reply with quoteQuote

Thanks, the updated Delphi API is now in the package.

An updated DLL is also in the package, which adds the option of an input device's WASAPIPROC returning 0 to stop the device (like a RECORDPROC) and fixes a loopback recording bug. A WASAPI version of the BASS "RECTEST" recording example has been added too.
Logged
radio42
Posts: 4030


« Reply #14 on: 30 Apr '10 - 16:18 »
Reply with quoteQuote

A new pre-version of BASS.NET is available here:
   www.un4seen.com/filez/4/Bass24.Net_pre.zip

It incorporates the latest BASS_DSHOW version (v2.4.0.8) as well as the latest BASSWASAPI version (v0.0.0.2).
Logged
jeffdavis
Posts: 293


« Reply #15 on: 30 Apr '10 - 17:08 »
Reply with quoteQuote

How about converting BASStest to using BASSWASAPI?

Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #16 on: 30 Apr '10 - 18:03 »
Reply with quoteQuote

I think the next examples to be ported will be LIVEFX and MULTI, but perhaps a BASSTEST port could come after that; it would basically be a matter of plugging multiple sources into a mixer, with the WASAPI part of it being much the same as in the CONTEST and SPEAKERS examples.
Logged
jeffdavis
Posts: 293


« Reply #17 on: 30 Apr '10 - 18:34 »
Reply with quoteQuote

I was just thinking that for those of us that use BASS to just play audio files as a player an example of the best way to use BASSWASAPI for Vista / Windows 7  OS.    A simple example of a media player that detects if BASSWASAPI can be used otherwise uses standard BASS.   And of course I'd like to see the demos in VB6 but thats just me.


 
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #18 on: 3 May '10 - 15:35 »
Reply with quoteQuote

Yes, an example for using WASAPI output when available, and BASS/DirectSound when not, could indeed be useful. I'll look into adding one.
Logged
Mike Wittman
Posts: 20


« Reply #19 on: 5 May '10 - 05:06 »
Reply with quoteQuote

Ian (or other informed sources);

I'm trying to use the WASAPI "Exclusive" mode to achieve a "bit-perfect" rendering of "lossless" audio.  I don't have a problem with the sample data being converted (up to 24 "bits per sample") into 32 bit FP data.  But I want to be sure that the soundcard is rendering at that original bps or better (ex., 96kHz, 2 Channel @ 24 bits per sample). 

In your BASS_WASAPI_GetInfo method; the "format" field will return the devices "bits per sample" (bps); which is useful when inspecting the "mixer" format.  However it does not seem possible to "set" this field in the BASS_WASAPI_Init for Exclusive mode.  I would also have expected to see this in the BASS_WASAPI_CheckFormat method.

When using the IAudioClient interface directly; I can test and inititalize this using "IsFormatSupported" and "Initialize" with the correct WaveFormatEx structure.

Using your implementation; how do I ensure that a valid "bits per sample" is correctly selected in the soundcard/device?

PS:  Nice job on the WASAPI package.  If I had to write this framework myself .. I'd have to quit my "day job"!
Logged
Pages: [1] 2 3 ... 12
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines