The MASM Forum

General => The Campus => Topic started by: Camper on June 02, 2017, 10:10:16 PM

Title: Creating a pure audio thread in x64
Post by: Camper on June 02, 2017, 10:10:16 PM
Hi,

So, I have this GUI in .net, and I want to create standalone audio applications using a VB:NET GUI and a p-invoked audio thread.
I was wondering what the scope f such a project wold be, given i'm a half decent audio programmer also somewhat versed in assembler
So I ultimately want to support multiple drivers and have the DAC and the audio thread inside an assembly file.
Is this a hard project to do?

regards,
Title: Re: The scope of creating a pure audio thread in x64
Post by: hutch-- on June 02, 2017, 10:33:39 PM
There are two things that come to mind, how do you call either a DLL from .NET or link a modules. The other is you need to know how to write the module or procedure that you want to call from .NET. If you can work those things out writing the assembler should be straight forward enough.
Title: Re: The scope of creating a pure audio thread in x64
Post by: jj2007 on June 02, 2017, 10:34:23 PM
Indeed, as Hutch wrote, this doesn't sound overly difficult. Do you have source code in other languages, VB, C, C++? What do you expect from assembler here, a speed gain?
Title: Re: The scope of creating a pure audio thread in x64
Post by: Camper on June 02, 2017, 11:23:05 PM
A speed gain shure, Maybe spend some time with assembler is a fun thing to do. It's a good thing to do with pen and paper.

It was my goal to have the entire thread go in assembler, and have a few outputs in the assembly for listing devices and sample rates in the GUI. But mostly one big thread representing both the DAC and the audio thread. A bit like computer controlled analog. So I need to learn the assembler way of generating sound and listing devices.  But I have no idea really about the task at hand.

Are there any examples that deal with this, i.e. moving some waveform to direct sound? That I can have a look at?
Trying to get a grip on both worlds.

JJ,  I made "this", and want to move on from there.


Title: Re: The scope of creating a pure audio thread in x64
Post by: Camper on June 05, 2017, 01:33:09 AM
I think about P-invoking some C code, and calling the assembly from the C code. It's actually ready made  :greenclp:

Title: Re: The scope of creating a pure audio thread in x64
Post by: Siekmanski on June 05, 2017, 02:39:40 AM
You want to enumerate sound-card devices in assembly?
Title: Re: The scope of creating a pure audio thread in x64
Post by: Camper on June 05, 2017, 02:54:55 AM
Yes, and have a higher end DS, ASIO and WASAPI interface. Or outputs at first.
I'm looking for the quickest way to start writing the functional audio code.
Thinking the problem with .net is that it has the DSP code as managed code.
Having it ready made in C is better.
Title: Re: The scope of creating a pure audio thread in x64
Post by: Siekmanski on June 05, 2017, 03:12:53 AM
Here are 2 examples, ASIO and DirectSound. I'm curious what it is you are going to write.
Why not skip the entire .NET code if your going to write DSP stuff?

Ik ben zeer nieuwsgierig als het om muziek applicaties gaat... :biggrin:
Title: Re: The scope of creating a pure audio thread in x64
Post by: Camper on June 05, 2017, 09:45:46 PM
Nice, Looks complicated, will try to learn a lot from this. The lib I was talking about was libsoundio.
The reason I want want to stick with VB.NET is I have "this" custom GUI made in it. It's very what I want from it, very tactile and accurate.
And almost finished. So maybe I can port it to assembler one day,

Maybe you like this Granular delay I made in 2012. It's a bit washed up in the x64 era. I want to go big this time. And make a standalone daw style synthesizer. To port into a VST if it stays under 10%. http://www.soundsystembrabant.com/
Title: Re: The scope of creating a pure audio thread in x64
Post by: Siekmanski on June 05, 2017, 10:24:46 PM
Kan je webpagina niet lezen, komt heel klein op mijn scherm.
Heb libsoundio even opgezocht maar heeft geen ondersteuning voor ASIO zie ik.
Title: Re: The scope of creating a pure audio thread in x64
Post by: Camper on June 06, 2017, 12:13:17 AM
Ok thx, welke browser? Zoom setting "internet explorer?"
VST Dll only (http://www.soundsystembrabant.com/index.php/component/attachments/download/54)

Ye, youre right need to gather some more data, im really agnostic to this stuff.. Yust mathematician and binary arithmetic nerd, need to learn a lot while trying to make stuff.

Title: Re: The scope of creating a pure audio thread in x64
Post by: Siekmanski on June 06, 2017, 01:58:22 AM
Yeah, you need to be a little bit of a math freak to do this kind of stuff.
Title: Re: Creating a pure audio thread in x64
Post by: Camper on June 07, 2017, 03:37:20 AM
But Thanks for the notification on my site, not going to fix it tho. This stuff breaks all the time with Explorer, it gets harder every time. I have the same issue with i.e 11. Firefox works fine. Going to convert to XHTML soon,

Your ASIO stuff looks great actually. Maybe I can have a couple of extra register violations building a switch. And having the code in another DLL. So you can have the DS and WASAPI or ASIO, getting the bytebuffer. But it's not by far an elegant solution. Or maybe run the same code in different loops? Im pretty hell bent on having DS because of the multiclient drivers, and WASAPI is must have too..

The enumerate app, what does it do?
Title: Re: Creating a pure audio thread in x64
Post by: Siekmanski on June 07, 2017, 09:28:08 AM
You could try checking for ASIO first then WASAPI and at last Directsound. ( if latency is a big deal )
Maybe create seperate libs pointing to the same sample buffer....

QuoteThe enumerate app, what does it do?

It finds all sound-cards connected to your computer.
Some sound-cards have multiple channels.
I've got a "Marian Trace Pro" sound-card with 6 stereo input channels and 8 stereo output channels.
So you can select your in and output channels or choose another sound-card.

(http://members.home.nl/siekmanski/enum.png)

here the ASIO output of my  Marian Trace Pro:

Siekmanski ASIO Sound Card Test..........


Number of ASIO drivers found: 1


Return value Asio function init: 1

DriverName          : TRACE PRO
Version             : 2

numInputChannels    : 12
numOutputChannels   : 16

inputLatency        : 800
outputLatency       : 800

BufferminSize       : 32
BuffermaxSize       : 2048
BufferpreferredSize : 800
Buffergranularity   : 16

Enum SampleRates:

8000
9600
11025
12000
16000
22050
24000
32000
44100
48000
88200
96000
152000
176400
192000

total SampleRates   : 15

Actual SampleRate   : 44100

Input Channel Infos:

Channel             : 0
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 1-2

Channel             : 1
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 1-2

Channel             : 2
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 3-4

Channel             : 3
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 3-4

Channel             : 4
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 9-10

Channel             : 5
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 9-10

Channel             : 6
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 11-12

Channel             : 7
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 11-12

Channel             : 8
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 13-14

Channel             : 9
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 13-14

Channel             : 10
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 15-16

Channel             : 11
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 15-16


Output Channel Infos:

Channel             : 0
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 1-2

Channel             : 1
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 1-2

Channel             : 2
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 3-4

Channel             : 3
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 3-4

Channel             : 4
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 5-6

Channel             : 5
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 5-6

Channel             : 6
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 7-8

Channel             : 7
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 7-8

Channel             : 8
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 9-10

Channel             : 9
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 9-10

Channel             : 10
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 11-12

Channel             : 11
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 11-12

Channel             : 12
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 13-14

Channel             : 13
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 13-14

Channel             : 14
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 15-16

Channel             : 15
Channel Group       : 0
Data Type           : 27
Name                : Trace PRO 15-16

NumClockSources     : 4

Index               : 0
AssociatedChannel   : -1
AssociatedGroup     : -1
IsCurrentSource     : 1
Name                : Internal

Index               : 0
AssociatedChannel   : -1
AssociatedGroup     : -1
IsCurrentSource     : 1
Name                : Internal

Index               : 0
AssociatedChannel   : -1
AssociatedGroup     : -1
IsCurrentSource     : 1
Name                : Internal

Index               : 0
AssociatedChannel   : -1
AssociatedGroup     : -1
IsCurrentSource     : 1
Name                : Internal


The driver can not convert the host data directly to the DMA buffer.
No output latency reduction by one block.

Press any key to continue...


Title: Re: Creating a pure audio thread in x64
Post by: mabdelouahab on June 07, 2017, 10:13:21 PM
Quote from: Siekmanski on June 05, 2017, 03:12:53 AM
Why not skip the entire .NET code if your going to write DSP stuff?
Siekmanski  are right and it is also the easiest way
I have no experience in sound but if he needs help in dealing with .net assembly project or assembly in .net project then I'm ready to help.
Title: Re: Creating a pure audio thread in x64
Post by: Camper on June 08, 2017, 02:56:47 AM
Pff man, "And direct sound". Feel a bit stupid now for having this tunnel vision. Waa, it works already with WASAPI drivers.
Have to take a leave of absence and some relaxing herbs to study this in great detail.
Thanks man!
Title: Re: Creating a pure audio thread in x64
Post by: Camper on March 29, 2019, 09:04:32 PM
Quote from: mabdelouahab on June 07, 2017, 10:13:21 PM
Quote from: Siekmanski on June 05, 2017, 03:12:53 AM
Why not skip the entire .NET code if your going to write DSP stuff?
Siekmanski  are right and it is also the easiest way
I have no experience in sound but if he needs help in dealing with .net assembly project or assembly in .net project then I'm ready to help.

Maybe it would be cool to do a VST "struct" plugin in MASM?
I could facilitate it, and chip in some DSP.