Geeks With Blogs
Thinking Kernel Mode ExAllocatePoolWithTag(KMScrapPad, sizeof(KMSCRAP), TAG_TKM);
New Page 1

{ Not invented here }

Unless I scribble this down somewhere, I will forget. So let me dump my memory . . 

Kernel Streaming is a fairly complicated topic. And to study this, the available resources are the DDK help documentation and the samples. AFAIK, there are no books written on this topic. And what is present online is also meager. 

The Streaming Devices (Video & Audio) subsection of the DDK help, has everything documented.

Now,  in order to emulate a virtual audio hardware, we have to write an Audio Miniport Adapter driver. The MSAVD sample source code can be used for this purpose.

WHDC Audio Device Technologies for Windows [http://www.microsoft.com/whdc/device/audio/default.mspx] 

Getting Started with WDM Audio Drivers [http://www.microsoft.com/whdc/device/audio/wdmaud-drv.mspx]

This is how the audio device stack will look like. 


System Audio Device (SysAudio.sys)
Kernel Mixer (Kmix.sys)
Streaming Class Driver (stream.sys) Port Class Driver (PortCls.sys)
USB Audio (USBAudio.sys)
USB Device  Adapter Driver
USB Controller Audio Device

The Adapter Driver is what we write and for a virtual audio device it will be a modified MSAVD driver. 

Modifying the MSAVD Driver to make your own virtual audio device.

In Kernel Streaming, every component is a Filter. Filters have input (sink) and output (source) pins. Data enters a filter through its input pin and leaves through the output pin. Every filter has a purpose :  to process the data flowing through them.

As an audio device (virtual or real), your hardware will have a range of audio data parameters which can be accepted. Or in other words, only data complying to a specific format and parameter range can be accepted by the input pins. This is called the property of the pin. 

Specify those ranges in the PinDataRangesStream static variable of the MSAVD source code. 

Now, in the WaveCyclic miniport there are two methods named CopyTo and CopyFrom for copying audio data to and from the audio device's  memory (DMA). Add code to those function to implement a virtual write and read and the minimal audio driver code is complete.

 

Posted on Wednesday, October 26, 2005 9:41 AM | Back to top


Comments on this post: Writing a virtual audio driver

# re: Writing a virtual audio driver
Requesting Gravatar...

Where can I found the MSAVD sample source code?

Thank you in advance
Left by Nadya on Nov 16, 2005 11:36 PM

# re: Writing a virtual audio driver
Requesting Gravatar...

You find it among the DDK samples

$DDK_INSTALL_DIR$\src\wdm\audio\msvad
Left by Sreejith S on Nov 20, 2005 8:06 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi Sreejith S

Thanks for the information.
I'm beginner in the C++ and driver's development.
What is the meaning of "miniport"? Can you tell me about its concept?

Left by Nadya on Nov 21, 2005 3:10 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Left by Sreejith on Dec 02, 2005 7:18 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi
I would like to write virtual audio which can send/recieved PCM data from network. How can make MSVAD to use sockets. If i use #include <winsock2.h> in basedma.cpp i am getting lots of erros.

Thanks
Krishna
Left by Krishna Reddy on Mar 06, 2006 11:55 AM

# re: Writing a virtual audio driver
Requesting Gravatar...

See "Remoting Your Toaster Using Kernel-Mode TCP/IP" at WD-3

http://www.wd-3.com/archive/RemoteToaster.htm

Since wd3 domain has expired, see google's cache

Left by Sreejith S on Mar 06, 2006 3:38 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi,
1. Is reboot required after installation? If so, is there any alternative to write a virtual audio driver that will not require reboot ?
2. Will this driver work on Win2000 & XP ?
Thanks,
Simhi
Left by Simhi on Mar 14, 2006 1:35 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
1. No, reboot is not required after installation.

2. Yes, will work on 2K and XP
Left by Sreejith S on Mar 14, 2006 3:25 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi,
Thanks. I have few follow-up questions:
1. What is the best way for this driver to pass data from/to user space application ?
2. Could IOCTL be used ?
3. Shoud I use direct or buffered IO ?
Thanks,
Simhi
Left by simhi on Mar 14, 2006 4:08 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Yes, IOCTLs are the way to go.

Direct IO is best suited if you are handling large amounts of data (more than a page).
Left by Sreejith S on Mar 15, 2006 5:42 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi,
I'm doing something on msvad now.
I have 2 questions to ask you.
1. Does msvad(simple) support kernel streaming?
2. If I want to use AMR codec, how to add? Can I use msvad(simple)?
Left by Zhaofeng on Mar 16, 2006 8:25 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Exactly which DDK has the MSVAD set?
Left by richard on Apr 02, 2006 9:44 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
XP DDK
Left by Sreejith S on Apr 08, 2006 7:47 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi, Sreejith
I'm now working on the MSVAD(Simple). I have a question about it.

1. You said "Yes, IOCTLs are the way to go.". But how can I get the handle of the MSVAD(Simple)?
2. I tried to use IoRegisterDeviceInterface() in AddDevice() of MSVAD(Simple), and then in my user mode application I use SetupDiGetDeviceInterfaceDetail() and CreateFile() to get the handle of the MSVAD device. Debugging in VC6++, it seems that I can get the handle of the MSVAD(Simple), but when I send IOCTL code using DeviceIoControl(), the call fails. Do you have any idea about this?

Thanks,
Left by Hadong on May 03, 2006 8:35 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi Sreejith S ,

would you send MSAVD sample source code to me,
i can't find it in win2k ntddk.
my email is lzcx_cn@yahoo.com.cn

TIA
Left by Alex on May 08, 2006 6:39 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi,

You may find it in WinDDK.
After installation at <drv>:\WinDDK\XXXX.XXXX\src\wdm\audio\msvad.

Xin
Left by xing_xin@yahoo.com on Jun 20, 2006 10:57 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
hi hadong

have you resolved your questions? that is, how to implement IRP_MJ_CREATE, IRP_MJ_CLOSE, IRP_MJ_DEVICE_CONTROL in MSVAD?
actaully, I encounter the same problem, would you please give me some hints?
thanks.
Left by weiji zheng on Jul 20, 2006 5:15 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi,
I want to receive data from Microphone using MSVAD but it seem MSVAD it design for render purpose only, not for capture.
I insert code into CopyFrom function and trace all the data but it alway zero.
Anybody have expierence in this issue ?

Duc
Left by Duc on Nov 28, 2006 1:06 PM

# Virtal Audio Driver Volume Control
Requesting Gravatar...
I have virtual audio driver that just sends data from render stream to capture stream.
It has Topology with MUTE and VOLUME nodes on render line and appropriate property handlers for them? How can I make sndvol32.exe to change volume level without multiplying amplitudes in render stream on a volume coefficient? Now it only shows volume level changer, but it doesn't change volume level actually.
Left by urukhai on Jan 19, 2007 5:54 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
I have problem with on my VAD with the ISR precision. The Timer is not precise enough so my audio sample rate is a bit wrong. It seems that even if I try to change the timer, the system refuses to be trigged (pMiniport->m_Port->Notify(pMiniport->m_ServiceGroup);)
if at least 10 ms passed since the last call. Then the trigger will be too late.
Is there a way to get a more precise timer or to force the system to accept triggers a little bit less than 10 ms ?
Left by fab on Jan 23, 2007 10:00 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi:

I built msvad(simple) from the DDK with no modification. It work to render/play but it will not allow for capture.

You said to add code to "WaveCyclic miniport there are two methods named CopyTo and CopyFrom"; what code are you talking about and will adding this code allow me to capture using msvad
Left by mikej on Feb 07, 2007 10:57 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
What does mavad(simple)exactly do?

My application demands a virtual driver where i need to process the audio data.

mic-->sound card-->virtual driver-->rocessing-->Virtual driver-->Audio Application(ex gtalk).

I installed SIMPLE and changed the sound setting is control panel.

IN device is Sound card driver
OUT device is MSVAD driver.

In the audio application(ex cool edit) I changed the

In device to MSVAD driver.
Out device to Sound card driver.

When I play a audio file in Media player and record in cool edit . I get junk data recorded not the file what I am playing in media player.

Is this possible with SIMPLE .

Please explain me how to modify the SIMPLE to do this type of task.I am electrical guy and totally ignorant about whats happening in these drivers.

Any help is appreciated.

Hariharan
Left by hariharan on Mar 01, 2007 11:16 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Interesting topic. I need to write a driver, also, but not an audio one. I am interested in the most efficient way of allocating memory to be used just by the driver. I need about 2 or 3 pages to be allocate at DriverEntry, and, when a certain event occurs, chunks of 8 pages. I've searched the net about this topic, but had no luck.

Thanks!
Nick
Left by Nick on Jul 30, 2007 12:21 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
hi, all

how can i send stream data form MSVAD to real sound cards??

how can i make app for control MSVAD??

thanx
Left by kisine on Dec 08, 2007 2:00 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
I need a virtual audio rendering driver.

Has ayone made msvad actually work here?


thanks,
Bx
Left by Bernt Ronningsbakk on Dec 14, 2007 7:40 PM

# re: ioctl for the msvad
Requesting Gravatar...
Please see
http://msdn2.microsoft.com/en-us/library/ms793658.aspx

When you are overwriting any of the DriverObject's dispatch function pointers, within your function you must forward the IRPs which you do not handle using PcDispatchIrp.
Left by sreejith on Mar 27, 2008 3:45 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
I need to write a virtual MIC driver. I have som HW that generates sound data and I what to write a Mic driver that e.g. Skype can use to receive this data. Is a minidriver/msvad the right way to go and does anybody know any examples I can use ?
Left by Maverick on May 18, 2008 9:27 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
I am creating a virtual audio device driver based on MSVAD. I am able to hear the sound. Actually the problem is when I am trying to play audio, live on other stream instead of writing it on
file. Some delay is getting introduced in render stream, which does
not happen when written into file. Quality of audio in live streaming
is little low as compared when written into file. I guess it might be
due to some read/write pointers issue managed by port class. So can
you please suggest me any reason for this ? Is there change required in FrameSize formula or Interval for DPC?

Any suggestion regarding this would really helpful to me.

Thanks in advance.
Left by swapnil on Oct 15, 2008 7:41 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
I am trying another way of VAD implementation. I have implemented WavePCI in my driver. My mapping calls of GetMapping () and ReleaseMapping () are working fine. Following are thing which I have done.

1. I created DmaChannel through NewMasterDmaChannel(), this works fine gives DmaChannel object. Passed as out parameter to NewStream ().
2. Allocated tables through AllocateCommonBuffer() call.
3. Created a timer object , DPC object which calls DPC after every interval(e.g. 10ms) and wrote a DPC in which I am calling Notify() of PortCls.
4. Methods of WavePCI interface are implemented one of them is Service () which is invoked after above Notfiy() call by PortCls.
5. This Service() gives call to ReleaseMapping()/GetMapping() methods saves their out parameters in a table as ac'97 does.

This is implemented as per MSDN documentation. Now the Driver runs continuously and consumes so many CPU cycles, the system slows down. But if I only obtain possible mappings in first GetMapping () call that is no MappingAvailable () then it runs smoothly. But still I do not get any audio only noise is produced. And one more thing I do get some value in VirtAddr pointer of GetMapping () .
I also tried with common table between Capture / Renderer streams, but that didn't help. With IDmaChannel channel implementation also I tried, and passed casted stream object through Newstream(), but that also didn't helped.

Is there something else also that in WavePCI it needs to be implemented. If anyone has any suggestion about then please reply ?
Left by swapnil on Oct 15, 2008 7:42 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
I also encountered the same problem with MSVAD as swapnil did. when I send the audio through RTP I find out that not enough PCM samples arrive to the CopyTo function, and as a result after a few seconds I have no PCM buffer left to and I cannot generate new packets.
Any idea ?

Left by Dan on Oct 23, 2008 12:14 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi,
Is Roman Divacky's driver completed ? Are you here ? Can we get his email - id ????
Left by swapnil on Dec 14, 2008 5:44 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
See this virtual sound driver:
http://www.shiningmorning.com/VirtualAudioStreaming/index.html
Left by ben on Mar 24, 2010 12:03 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi

Im in need of a virtual audio driver that works with Windows Vista and Windows 7 (with source code). Would anyone sell it to me?

Thanks Tobias

gtobias
att
gmx.net
Left by tobias on Jul 19, 2010 3:58 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
hello, i need to write audio driver which wil work separately for each individual user session
please help me for the same.
Left by rajesh s. butala on Sep 16, 2010 7:44 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
In signal processing, a filter is a device or process that removes from a signal some unwanted component or feature. Filtering is a class of signal processing, the defining feature of filters being the complete or partial suppression of some aspect of the signal. Most often, this means removing some frequencies and not others in order to suppress interfering signals and reduce background noise. However, filters do not exclusively act in the frequency domain; especially in the field of image processing many other targets for filtering exist.
Cluj Hotels
Left by Brasov Hotels on Jul 10, 2011 1:20 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
A digital filter system usually consists of an analog-to-digital converter to sample the input signal, followed by a microprocessor and some peripheral components such as memory to store data and filter coefficients etc. Finally a digital-to-analog converter to complete the output stage. Program Instructions (software) running on the microprocessor implement the digital filter by performing the necessary mathematical operations on the numbers received from the ADC. In some high performance applications, an FPGA or ASIC is used instead of a general purpose microprocessor, or a specialized DSP with specific paralleled architecture for expediting operations such as filtering.
Brasov Hotels
Left by Brasov Hotels on Jul 10, 2011 1:25 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
A multifunction device is a single adapter card that incorporates two or more separate functions (or subdevices). A multifunction device can contain two or more audio subdevices. It may also span device classes. A device containing audio and modem subdevices, for instance, belongs to both the media class and the modem class. A multifunction device occupies one location on its parent bus but contains more than one function. Combination printer/scanner/fax devices and modem/network cards are common multifunction devices. In a multifunction device, the individual functions are independent. This means the functions must have the following characteristics:
The functions cannot have start-order dependencies. The resource requirements for one function cannot be expressed in terms of the resources of another function (for example, function1 uses I/O port x and function2 uses port x + 200). Each function must be able to operate as a separate device, even if it is serviced by the same drivers as another function.
Timisoara Hotels
Left by Timisoara Hotels on Jul 10, 2011 1:35 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Additionally, the following requirements must be met so that a multifunction device can be correctly configured on an NT-based platform: Each function on the device must be enumerated. Resource requirements for each function must be communicated to the PnP manager. There must be INF files and drivers for each function. The component responsible for each of these tasks depends on the multifunction standard for the device's parent bus, the extent to which the device conforms to the standard, and the capabilities of the parent bus driver. If the device complies with the multifunction standards for its bus, your driver requirements are significantly reduced. Industry-wide multifunction standards have been defined for the PC Card and PCI buses.
Bucharest Hotels
Left by Bucharest Hotels on Jul 10, 2011 1:40 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
If you are working with a multifunction DVD/CD-ROM device used for data storage (not for audio/video playback) on a Windows XP or later operating system, you should use the system-supplied WDM DVD class driver, which treats the device as a single logical unit. For Windows 2000 and Windows 98, you should treat the device as two logical units (so it will appear with two drive letters). If the DVD capabilities are combined with some other type of function, you should treat the device as a single logical unit and supply a class driver that implements common command sets for all the features of the device.
Sibiu Hotels
Left by Sibiu Hotels on Jul 10, 2011 1:43 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
No hardware compatibility list for Windows 7 yet, even at this late stage. Sound cards are a definite issue, especially the Asus MB ones created by Creative. The final release of Windows 7 renders even more sound cards useless. Most of the fuxes that worked with the beta releases of Windows 7 do nor work anymore. Good luck, I'm waiting for the list too.Rent A Car Timisoara
Left by IoanaRentacar on Jul 15, 2011 4:51 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Here is an actual list of what works on Windows 7 64x/32x
33-124 USB Microphone RadioShack Corporation Compatible with Windows 7
33-331 XLR to Mini USB Microphone Adapter RadioShack Corporation ----
AIM AS301 USB Audio Formosa21 Inc. Compatible with Windows 7
AMD HDMI Controller ATI Technologies, ULC Compatible with Windows 7
AMD HDMI Controller Advanced Micro Devices, Inc. Compatible with Windows 7
AS301DTS USB Audio Formosa21 Inc. Compatible with Windows 7
AS301DTS USB Audio Driver Formosa21 Inc. Compatible with Windows 7
AS302DTS Device Formosa21 Inc. Compatible with Windows 7
AS302DTS USB AUDIO Formosa21 Inc. Compatible with Windows 7
ASUS Xonar Audio Device C-Media Electronics, Inc. Compatible with Windows 7
Bucharest Apartments
Left by CosminaEastcomfort on Jul 15, 2011 4:56 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
and:

Microsoft LifeCam Cinema Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam HD-5000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam HD-5001 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam HD-6000 for Notebooks Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam NX-3000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam NX-6000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam Show Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-1000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-2000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-3000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-5000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-5500 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-7000 Microsoft Corporation Compatible with Windows 7
Microsoft LifeCam VX-800 Microsoft Corporation Compatible with Windows 7
Microsoft LifeChat LX-3000 Microsoft Corporation Compatible with Windows 7
Bucharest Apartments
Left by CosminaEastcomfort on Jul 15, 2011 4:56 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Any example sources out there? :)
Left by roger on Oct 10, 2011 10:49 PM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hi Guys,
I have modified MSVAD simple and able to stream audio through TDI to other PC in XP. But when streaming in WIN 7 with WSK, some data is dropping. Do I need to change anything with respect to WIN 7 in MSVAD?. Also I wanted to know who(port or miniport) maintains timers or synchronization?
Left by Hanuamnth on Mar 15, 2012 12:53 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
Hiya
I've been looking around the web for a virtual audio driver that supports two soundcard in one output source. Though i've only manage to locate virtual audio cable which doesnt work perfectly in win7 and it existed with alot of bugs. Winamp's output stacker could only play mp3s and win7 pretty much crashes alot. So i thought maybe it's time i shud try to create one that works. Any advise or suggestion? Thankyou..
Left by darkskies on Jun 17, 2012 7:04 AM

# re: Writing a virtual audio driver
Requesting Gravatar...
I have modified MSVAD simple and able to stream audio through TDI to other PC in XP. But when streaming in WIN 7 with WSK, some data is dropping. Do I need to change anything with respect to WIN 7 in MSVAD?. Also I wanted to know who(port or miniport) maintains timers or synchronization? servidores dedicados con windows
Left by alia on Nov 10, 2012 2:41 PM

Your comment:
 (will show your gravatar)


Copyright © Sreejith S | Powered by: GeeksWithBlogs.net