Steps on programing with ASIO?????????
-
- KVRer
- Topic Starter
- 2 posts since 20 Nov, 2005
Hi every body, i´m a newbie in the computer music programming, but an experimented computer music software user. That fact encourage me too much because now i could program a sinewave generator using only the api´s. Now i´m about to program the same app with directsoud.
I need your help because i want to program the same stuff using the ASIO drivers. i have the ASIO SDK but i just dont get it.
Compiler: visual c++ , visual c++.net
I need your help because i want to program the same stuff using the ASIO drivers. i have the ASIO SDK but i just dont get it.
Compiler: visual c++ , visual c++.net
-
- KVRist
- 59 posts since 27 Apr, 2005 from Fu%$ing "Katoland"
Hi there,
Just use Portaudio library, it's very simple and can be used with WinMM, DX & ASIO interfaces. It is open source so you can see how ASIO stuff was coded.
I'm using it with ASIO in a simple vst host I wrote for testing my vst plugin and it works great
Just use Portaudio library, it's very simple and can be used with WinMM, DX & ASIO interfaces. It is open source so you can see how ASIO stuff was coded.
I'm using it with ASIO in a simple vst host I wrote for testing my vst plugin and it works great
-
- KVRer
- 27 posts since 22 Nov, 2005
Hi
If you're interested I can post a C++ wrapper I once wrote for the ASIO sdk, it allows you to start/stop a card and read/write samples from it in a convenient way.
Portaudio is not too bad, but it sometimes drops the first buffers (not with Asio I think, but it does with mme)
If you're interested I can post a C++ wrapper I once wrote for the ASIO sdk, it allows you to start/stop a card and read/write samples from it in a convenient way.
Portaudio is not too bad, but it sometimes drops the first buffers (not with Asio I think, but it does with mme)
-
- KVRist
- 456 posts since 15 Oct, 2004 from SF, CA
that is also helpful for me...stinos wrote:Hi
If you're interested I can post a C++ wrapper I once wrote for the ASIO sdk, it allows you to start/stop a card and read/write samples from it in a convenient way.
Portaudio is not too bad, but it sometimes drops the first buffers (not with Asio I think, but it does with mme)
-
- KVRer
- 27 posts since 22 Nov, 2005
here you go:
I wrote a little sample to show how to use it, it will multiply the input with 2 and write it to the output for approx. 5 seconds.
All processing happens in the callback; if you have a gui or another thread communicating with your processing (eg to set m_dGain or if using vst plugins) it's a good idea to use mutexes.
files (includes container classes used):
http://users.skynet.be/parklife/asiowsrc.rar
code comes without any warranty but may be used and modified to taste ;-]
It's only a minor part of a bigger framework for dsp, and it's not completely finished, eg only returns 16bit, lack of decent error checking,..
I have succesfully tested the code on 3 soundcards (LynxONE, Rme Multiface, MAuddio Audiophile), but I'm not sure it works for any asio driver.
Let me know something when it's usefull/you find bugs/.. !
Greetz!
I wrote a little sample to show how to use it, it will multiply the input with 2 and write it to the output for approx. 5 seconds.
All processing happens in the callback; if you have a gui or another thread communicating with your processing (eg to set m_dGain or if using vst plugins) it's a good idea to use mutexes.
Code: Select all
//object passed to callback
class CallbackData
{
public:
CallbackData() :
m_dGain( 1.0 ),
m_pWrapper( 0 ),
m_pScratchBuf( 0 )
{
}
~CallbackData()
{
delete m_pScratchBuf;
}
void Init( iowrappers::AsioWrapper* const ac_pWrapper, const double ac_dGain )
{
m_dGain = ac_dGain;
m_pWrapper = ac_pWrapper;
m_pScratchBuf = new CChanBufShort( ac_pWrapper->mf_nGetIChan(), ac_pWrapper->mf_nGetBuffSize(), true );
}
double m_dGain;
AsioWrapper* m_pWrapper;
CChanBufShort* m_pScratchBuf;
};
//callback
void pCallback( void* pData )
{
CallbackData* p = (CallbackData*)pData;
const double c_dGain = p->m_dGain;
const unsigned c_nChan = p->m_pWrapper->mf_nGetIChan();
const unsigned c_nSize = p->m_pWrapper->mf_nGetBuffSize();
const CChanStrShort& c_Input = p->m_pWrapper->mf_nReadSamples();
CChanBufShort* Scratch = p->m_pScratchBuf;
for( unsigned i = 0 ; i < c_nChan ; ++i )
{
for( unsigned j = 0 ; j < c_nSize ; ++j )
{
Scratch->mp_SetSample( i, j, c_Input( i, j ) );
}
}
p->m_pWrapper->mf_nWriteSamples( *Scratch );
}
/**
* ACTUAL CODE STARTS HERE
*************************/
const unsigned c_nChannels = 2;
const unsigned c_nBufferSize = 512;
const unsigned long c_lSampleRate = 48000;
AsioWrapper p;
CallbackData myData;
t_DriverNames* pDrv = p.mf_pGetDriverNames();
if( pDrv->mf_nGetNumItems() == 0 ) //no asio drivers found
return 0;
//open first driver found
if( p.mf_bOpenDriver( pDrv->mf_GetItem( 0 ), c_lSampleRate, c_nBufferSize, c_nChannels, c_nChannels, &myData, &pCallback ) )
{
myData.Init( &p, 2.0 );
p.mf_bStart();
Sleep( 5000 );
p.mf_bStop();
}
delete pDrv;
http://users.skynet.be/parklife/asiowsrc.rar
code comes without any warranty but may be used and modified to taste ;-]
It's only a minor part of a bigger framework for dsp, and it's not completely finished, eg only returns 16bit, lack of decent error checking,..
I have succesfully tested the code on 3 soundcards (LynxONE, Rme Multiface, MAuddio Audiophile), but I'm not sure it works for any asio driver.
Let me know something when it's usefull/you find bugs/.. !
Greetz!