LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ASIO interface for LabVIEW

Hello everyone,
I’m excited to share a new library I’ve developed to interface ASIO devices with LabVIEW. You can find the library attached to this message.
 
For this initial release, I’ve focused on supporting devices that use int32 as the data type, as these are the devices I’ll primarily be working with. Most modern sound cards with ASIO support seem to use int32, based on my experience. That said, I’m open to adding support for other data types if this library proves useful to others and there’s a demand for it—please feel free to let me know your needs!
 
I’m aware of the existing WaveIO library for interfacing LabVIEW with ASIO devices. However, it doesn’t offer functionality for synchronous measurements, which is a critical requirement for my application. To address this, I decided to create my own library tailored to that need.
 
Included in the attached zip file is an example VI. This VI scans for all ASIO devices on the system and retrieves the input and output channel names. For demonstration purposes, it allows selection of one input and one output channel. Users can choose between continuous measurement or synchronous measurement. For synchronous measurements, you’ll need to create the stimulus and provide it to the stream. For this first release, I’ve set the buffer size to 1024.
 
Looking forward to your feedback!
Message 1 of 16
(778 Views)

I'm super interested it trying out your ASIO driver.  I have put together some LV for audio experiments using a Behringer UMC404HD, 4 channel interface. With the standard Windows DirectX drivers I can only access all 4 channels if I split them into 2 stereo pairs, each with it's own buffer, and I loose phase coherency between all 4 channels. ASIO should, I believe, fix this.

I'm using LabVIEW 2024 Q3 Community Edition which is 32 bit. However, your driver appears to be 64 bit. 

Can you possibly recompile it for 32 bit?

 

Many thanks,

Liam. 

0 Kudos
Message 2 of 16
(592 Views)

Hi Liam,

 

Attached is the 32-bit version of the ASIO DLL. I do not have 32-bit LabVIEW on my system, so I could not test the DLL, but I just recompiled the code in Visual Studio with x86 as the target platform. Please test the attached DLL and let me know if it works.

Message 3 of 16
(547 Views)

Thanks LVCoder for superfast response.

That seems to work. I was able to run your ASIO_Input_Output_LV.vi in LV2024 Q3 Community Edition. It detects can send / receive audio on all four channels on the UMC404HD (one at a time as you have coded).   

I still have to incorporate your driver and vi's into my code to test them properly with all four channels simultaneously. 

 

Cheers, Liam.

Message 4 of 16
(536 Views)

sounds great. let me know if you need any help making the code work for multichannel I/O.

0 Kudos
Message 5 of 16
(528 Views)

LVCoder,

 

It has been some time since I looked at this. I'm now trying unsuccessfully to understand some of the DLL library calls used in your VIs.

Specifically, can you share more info on the following...

ASIO_LV_DLL.dll:writeToStream

ASIO_LV_DLL.dll:readFromStream

These appear to support only a single channel. How can these be used for multichannel?

 

Many thanks,

 

Liam.

 

 

 

0 Kudos
Message 6 of 16
(278 Views)

Hi LVCoder.  I think I figured it out but I needed to modify one of your VIs.

 

What was unclear to me was that the sample data in the library calls for multi channel is stored in the same array as single channel, each channel concatenated.

The changes I made to your ASIO_LV_Perform_Sync_Measurement.vi were as follows...

 

Remove the 'index array' on the 'recording' output (channel 1 only) and instead return the full 2D array with all channels (renamed 'recordings').

Change the read chunk size from 1024 to 512. I got some very strange behaviour with values other than 512. e.g. using 1024, some channel recorded data missing (replaced by zeros) on every second call to 'readFromStream'. The value 512 works independent of the selected buffer size. I've tested with buffer sizes 2048, 1024, 512, 256. Yes, even buffer size 256 works with a read chunk of 512!

leemkuny_0-1747607361125.png

 

Below you can see the result of my simple multichannel test. 

leemkuny_1-1747607644854.png

 

This is a simple external loopback check on the UMC404HD. each output/input with a different frequency sinewave. Note that the first 512 samples recorded are always zeros. After that the inputs are recorded but there is a further latency delay (~825 samples) before the output waveforms appear. 

 

My test code and the the modified 'ASIO_LV_Perform_Sync_Measurement_edit2.vi' are attached. 

 

Please check if the code works for you. Any input you have on the magic number 512 would be welcome.

 

Cheers, Liam.

 

 

0 Kudos
Message 7 of 16
(243 Views)

Hi Liam,

 

Could you print the device info and check what the preferred buffer size returned by ASIO_Get_All_Device_Info.vi ? 

There is nothing magical about the number 512 in the ASIO driver code, but all the internal working buffers in the code are of the preferred buffer size set by the ASIO driver in the hardware. If the preferred buffer size returned by UMC404HD is 512, then that would answer the question of why other buffer sizes are giving strange behavior.

 

I could not run your updated vi since I am still running vintage LabVIEW 2014. I plan to update to the latest version sometime next month.

0 Kudos
Message 8 of 16
(195 Views)

Hi LVCoder. That explains. 

 

Below is the device info for the UMC404HD with sampling frequency equal 48000. The preferred buffer size is 512.

leemkuny_0-1747817545898.png

I had noticed since my last post that if I change the sample frequency, I need to change the buffer size accordingly...

Fs = 44100 or 48000, Buffer = 512

Fs = 88200 or 96000, Buffer = 1024

Fs = 176400 or 192000, Buffer = 2048

 

This tallies with the device info, e.g. for 96000

leemkuny_1-1747817740492.png

 

I would like to be able to program the buffer size rather than using preferred value. This should allow me to reduce latency. How can this be done?

 

I've attached v14 files which I hope work for you.

 

Cheers, Liam.

 

0 Kudos
Message 9 of 16
(173 Views)

Hi Liam,

 

I could not open the ASIO_LV_Perform_Sync_Mesurement_edit2_v14.vi as LabVIEW says it's saved in LV24.

 

However, I modified the ASIO dll so that the buffer size is now user-defined. When the ASIO device is initialized, the buffer size is set to the preferred buffer size, but the user calls "ASIO_LV_Set_Buffer_Size.vi" to change the internal buffer size. Make sure to put the same buffer size in your audio interface driver software.

 

Attached are the latest DLL files and ASIO vis.

 

Let me know if this fixes the issue.

0 Kudos
Message 10 of 16
(150 Views)