Go Back   Home > Forums > Source & Line > PC Based

PC Based Computer music servers, crossovers, and equalization

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 1st July 2012, 11:05 AM   #11
diyAudio Member
 
Join Date: Feb 2009
Location: UK
Just a note about what you can do with a PC when it comes to DSP. Your PC has a performance measured in the tens of GFLOPS! It won't even break into a sweat for most audio processing applications.

In audio, the most obvious thing might be to implement an active crossover. You could emulate standard analogue filters using IIR filtering (Infinite Impulse Response) filters, but the most exciting possibilities lie in using FIR (Finite Impulse Response) filters to implement Linear phase filters Linear phase - Wikipedia, the free encyclopedia or even Digital Room Correction Digital room correction - Wikipedia, the free encyclopedia.

At its heart is the idea of convolving (Convolution - Wikipedia, the free encyclopedia) the incoming audio with a pre-defined impulse response. The impulse response can be that which gives you a linear phase band pass filter, or the inverse of your listening room's impulse response - or a combination of the two i.e. you can apply individual room correction to each driver at the same time as the crossover filtering.

On the surface, convolution looks as though it should be an incredibly processor-hungry activity. However, this isn't the case because of the Fast Fourier Transform (FFT) and the 'Convolution Theorem' which states that convolution in the time domain is the exact equivalent of multiplication in the frequency domain. All you have to do is calculate the forward FFTs of your filter's impulse response and incoming audio. Multiply them together using complex arithmetic then take the inverse FFT to get your convolved audio. Because the FFT is a very efficient operation, and it scales in complexity with only the log of the size of the input array, it is possible to do real time convolution of huge FIR filters.

The number of FIR 'taps' you can process on a PC is almost incredible.The Open Source application BruteFIR (http://www.ludd.luth.se/~torger/brutefir.html#whatis) can process over 3 million taps at 44.1kHz sample rate on a 1GHz Athlon. Most processors are much faster than this so will far exceed even that unbelievable figure.

BruteFIR is based on the FFTW library (FFTW Home Page), which is also what I have used for my playing with active crossovers. For the complex multiplication I have simply used the following inefficient code:

/************************************************** ***************************/
// complex structure definition
struct cpx
{
double real;
double imag;
};
/************************************************** ***************************/
struct cpx prod(struct cpx x,struct cpx y)
{
struct cpx z;

z.real = x.real * y.real - x.imag * y.imag;
z.imag = x.imag * y.real + x.real * y.imag;
return z;
}
/************************************************** ***************************/

So to implement an active crossover:
1. Define filter function for each driver (frequency and phase response) as an array of complex numbers.
2. Take the inverse FFT to get the impulse response of the filter.
3. Smooth it with a Hamming window or similar.
4. Take the forward FFT to get the pre-defined filter smoothed frequency response (only have to do this once before 'runtime').

5. Continuously assemble FFT arrays of incoming audio as real values only.
6. Take the forward FFT of the audio.
7. Complex multiply it by the filter's (previously-defined) frequency response.
8. Take the inverse FFT to get the audio convolved with the filter's impulse response.
9. Use the Overlap-Add method Overlap?add method - Wikipedia, the free encyclopedia to continuously produce the filtered output for each driver (it is not necessary to use 'windowing' at the output stage).

This, of course, is complicated by fact that FFTs are symmetrical about the Nyquist point, so the FFT arrays have to be assembled in symmetrical mirrored form. Overlap-add requires the arrays to be zero padded to a larger size before being added into the output buffer etc.

It takes a while to get your head around it all, but I will endeavour to 'minimalise' my active crossover code and place it here later.

Last edited by CopperTop; 1st July 2012 at 11:12 AM.
  Reply With Quote
Old 5th July 2012, 10:03 PM   #12
diyAudio Member
 
steph_tsf's Avatar
 
Join Date: Mar 2008
A few questions about the framework:

Have you tried with a recent PC motherboard featuring the Realtek HD Audio subsystem (three line-level stereo minijacks as outputs)?

On an quite old PC not featuring the Realtek HD Audio, have you tried attaching a CM6206-based USB multichannel audio board ?

Have you tried using ASIO4ALL for converting an on-board Realtek HD Audio subsystem, or a CM6206-based USB attachement, into an ASIO peripheral?

Have you tried VAC (Virtual Audio Cable) for the ASIO signal routing?
  Reply With Quote
Old 6th July 2012, 08:38 AM   #13
diyAudio Member
 
Join Date: Feb 2009
Location: UK
Quote:
Originally Posted by steph_tsf View Post
A few questions about the framework:

Have you tried with a recent PC motherboard featuring the Realtek HD Audio subsystem (three line-level stereo minijacks as outputs)?

On an quite old PC not featuring the Realtek HD Audio, have you tried attaching a CM6206-based USB multichannel audio board ?

Have you tried using ASIO4ALL for converting an on-board Realtek HD Audio subsystem, or a CM6206-based USB attachement, into an ASIO peripheral?

Have you tried VAC (Virtual Audio Cable) for the ASIO signal routing?
Hi steph. I'm afraid I have to answer in the negative to testing with all those permutations. My tests are limited to Creative X-Fi, and an older Audigy 2. I have previously used BASS successfully with an M Audio 2496 card. The PCs I have used are old Dell Mini towers, plus a Sony Vaio desk top machine.

In principle, I don't see why it shouldn't work with any PC with ASIO-capable card/chipset, providing the drivers are correct.

I did spend a little while looking into the pros and cons of virtual audio cables vs. two sound cards linked with SPDIF etc. I was delighted, however, to find that it was possible to use a single sound card as the simultaneous destination for media player applications, the source for my DSP program, and the destination for the processed audio. This must be the neatest way to do it, surely..?
  Reply With Quote
Old 25th July 2012, 10:09 PM   #14
diyAudio Member
 
steph_tsf's Avatar
 
Join Date: Mar 2008
hello,

installed bass.net

created a new CLR Console project on Microsoft Visual C++2010
entered the bare bones framework C source code (from above)

added bass.net in system references using the solution navigator
copied bass.dll and bassasio.dll in project subdirectory

warnings and errors at the .exe generation stage
could not generate the executable
see attached .zip

any advice welcome
Attached Images
File Type: jpg CopperTop (CLR Console) 0.10.jpg (291.6 KB, 150 views)
Attached Files
File Type: zip CopperTop (CLR Console) 0.10.zip (2.9 KB, 7 views)

Last edited by steph_tsf; 25th July 2012 at 10:31 PM.
  Reply With Quote
Old 25th July 2012, 10:44 PM   #15
diyAudio Member
 
Join Date: Feb 2009
Location: UK
Could you try changing line 162 to this?:
BASS_ASIO_ChannelEnable(OUTPUT_CHAN_TYPE, START_CHAN, (ASIOPROC*) AsioOutProc,0);
  Reply With Quote
Old 26th July 2012, 12:45 AM   #16
diyAudio Member
 
steph_tsf's Avatar
 
Join Date: Mar 2008
Quote:
Originally Posted by CopperTop View Post
Could you try changing line 162 to this?:
BASS_ASIO_ChannelEnable(OUTPUT_CHAN_TYPE, START_CHAN, (ASIOPROC*) AsioOutProc,0);
Unfortunately, the linker needs to know about START_CHAN. The linker generates the following report :


1>------ Build started: Project: CopperTop (CLR Console) 0.10, Configuration: Debug Win32 ------
1> CopperTop (CLR Console) 0.10.cpp
1>CopperTop (CLR Console) 0.10.cpp(134): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdio.h(304) : see declaration of 'scanf'
1>CopperTop (CLR Console) 0.10.cpp(143): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdio.h(304) : see declaration of 'scanf'
1>CopperTop (CLR Console) 0.10.cpp(147): error C2440: '=' : cannot convert from 'const char *' to 'char *'
1> Conversion loses qualifiers
1>CopperTop (CLR Console) 0.10.cpp(163): error C2065: 'START_CHAN' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  Reply With Quote
Old 26th July 2012, 08:12 AM   #17
diyAudio Member
 
Join Date: Feb 2009
Location: UK
Quote:
Originally Posted by steph_tsf View Post
Unfortunately, the linker needs to know about START_CHAN.
Oops, sorry. That should be

BASS_ASIO_ChannelEnable(OUTPUT_CHAN_TYPE, ASIO_START_CHAN, (ASIOPROC*) AsioOutProc,0);

Hopefully that should solve it.
  Reply With Quote
Old 28th July 2012, 09:49 PM   #18
deandob is offline deandob  Australia
diyAudio Member
 
Join Date: Oct 2002
Location: Brisbane, Australia
CopperTop,

For clarity, I assume you are using the standard audio inputs and processing with BASS then sending to the standard outputs. Having programmed with BASS for a couple of years (great library!) I have thought of a similar concept but potentially more flexible:
- Use virtual soundcard software that means that any software player can be used, rather than mucking around with 2 soundcards, loopback etc. The Windows DDK has sample code MSVAD (virtual audio driver) that installs as a software soundcard which can be used as your PC default soundcard.
- Route the stream from MSVAD to a user mode application running on the PC that runs the bass libraries. You could enhance MSVAD to also expose a soundcard input, directing the bass code to use as input, but it would be cleaner to use in memory buffer transfer (the msvad sample shows how).
- Once in BASS, you could use the BASS DSP libraries but I would prefer to use VST for highest quality & features. Having played with VST plugins with BASS, it works but sometimes the plugin UI gets screwed up.
- Bass then outputs to your selected output soundcard.

This way you have a desktop 'DSP' application that hosts the VST plugins via BASS and is completely flexible for any audio player (eg. players like Zune that can't select the output audio device).

I have compiled MSVAD and got the basics working but have not had time to explore this further (I program in VB , my C++ is rusty which doesn't help).
  Reply With Quote
Old 29th July 2012, 12:47 AM   #19
diyAudio Member
 
Join Date: Feb 2009
Location: UK
Quote:
Originally Posted by deandob View Post
CopperTop,

For clarity, I assume you are using the standard audio inputs and processing with BASS then sending to the standard outputs. Having programmed with BASS for a couple of years (great library!) I have thought of a similar concept but potentially more flexible:
- Use virtual soundcard software that means that any software player can be used, rather than mucking around with 2 soundcards, loopback etc. The Windows DDK has sample code MSVAD (virtual audio driver) that installs as a software soundcard which can be used as your PC default soundcard.
Hi deandob

I think I am using a neater solution than that:

Providing the drivers/control applet allow it, it is possible for a single sound card to function simultaneously as
1. The stereo destination for any software player (this just needs you to set the sound card as the default destination in Windows Control Panel. OR the sound card can act as a hardware input interface -line in, SPDIF etc.).
2. The stereo source for your own DSP application (just choose Wave in BASS as your input if you want to process the output from software players. OR select line , SPDIF etc. to process hardware inputs);
3. The multi-channel destination for your own DSP application e.g. eight analogue output channels. (Just send your eight outputs over ASIO from your BASS-based application)

No Virtual Sound cards in sight and, naturally, all the sample clocks are locked together.

Some sound cards and their drivers insist on providing a direct route from the input to the output, but even this may not necessarily be a huge problem, as it may only take up two of eight outputs. However, the impression I am getting is that the more professional cards will allow you to provide the functions that I list above, all at the same time, with no direct link from input to output.

Certainly this arrangement is possible with the humble Creative Audigy 2 (provided you use the open source Kx Project drivers and edit the DSP/router configuration), and it definitely works with the Creative X-Fi and its standard drivers.

I've been using it for a while and, as far as I can tell, it's that rare thing - a perfect solution. In fact, I worry that I'm missing something when people talk about needing two sound cards or commercial Virtual Sound card software, as these all involve extra complexity, expense and non-bit-perfect resampling...
  Reply With Quote
Old 29th July 2012, 03:19 AM   #20
deandob is offline deandob  Australia
diyAudio Member
 
Join Date: Oct 2002
Location: Brisbane, Australia
OK, I understand, you are relying on the routing features of the soundcard, I did something similar with EMU driver Patchmix on my previous HTPC (now using Lynx but the driver/mixer isn't as powerful) and it does work well.
I didn't know BASS could capture the output stream of software players by just selecting WAVE as the input, I'll try that.

Sample clocks are not an issue here as the PC will be processing async, however there will be a latency delay but with a modern PC it would be minimal.

What I am talking about would be independent of the soundcard and an integrated software solution using MSVAD and BASS. I am planning on using this approach to send the DSP processed audio stream via USB to a DIY DAC in multichannel. Maximum flexibility but coding needed!
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FS: Frequency Allocator PC crossover and DSP program jdubs Swap Meet 2 16th May 2012 03:28 AM
What DSP is suitable for audio? Snickers-is Parts 2 1st June 2006 03:50 AM
PC DSP crossover. Anyone interested in testing? Thunau Multi-Way 0 26th February 2006 11:14 PM
DSP Audio reverb Gold_xyz Digital Source 0 13th December 2005 03:54 PM
How come the bones in take-out chicken are so soft? Cal Weldon The Lounge 6 5th February 2005 02:32 PM


New To Site? Need Help?

All times are GMT. The time now is 03:24 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2