[SOLVED] Portaudio ASIO structure conversion help

Just starting out? Need help? Post your questions and find answers here.
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

[SOLVED] Portaudio ASIO structure conversion help

Post by AndyMK »

C

Code: Select all

    int outputChannelSelectors[1];

    asioOutputInfo.size = sizeof(PaAsioStreamInfo);
    asioOutputInfo.hostApiType = paASIO;
    asioOutputInfo.version = 1;
    asioOutputInfo.flags = paAsioUseChannelSelectors;
    outputChannelSelectors[0] = 1; /* skip channel 0 and use the second (right) ASIO device channel */
    asioOutputInfo.channelSelectors = outputChannelSelectors;
PB

Code: Select all

Dim outputchannelselectors(1)

Define asio_info.PaAsioStreamInfo
asio_info\size = SizeOf(asio_info)
asio_info\hostApiType = #paASIO
asio_info\version = 1
asio_info\flags = #paAsioUseChannelSelectors
outputchannelselectors(0) = 1
asio_info\channelSelectors = outputchannelselectors
Is the array part correct? I am not getting the desired result
Last edited by AndyMK on Sun May 15, 2022 10:14 am, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Portaudio ASIO structure conversion help

Post by infratec »

An int in C is a long in PB.
This is a difference if you use PB x64
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Portaudio ASIO structure conversion help

Post by AndyMK »

The struct for PaAsioStreamInfo

Code: Select all

unsigned long 	size
PaHostApiTypeId 	hostApiType
unsigned long 	version
unsigned long 	flags
int * 	channelSelectors
PB

Code: Select all

Structure PaAsioStreamInfo Align #PB_Structure_AlignC
  size.l
  hostApiType.l
  version.l
  flags.l
  *channelSelectors
EndStructure
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Portaudio ASIO structure conversion help

Post by infratec »

Code: Select all

Dim outputchannelselectors.l(1)
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Portaudio ASIO structure conversion help

Post by AndyMK »

I already tried it and i still get output on the same channel
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Portaudio ASIO structure conversion help

Post by infratec »

It is nearly impossible to help without a code to test.

Build a small sample code which is runable, then I can look deeper inside.
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Portaudio ASIO structure conversion help

Post by AndyMK »

https://orangetek.net/test/portaudio_x64.zip

You will need a soundcard with more than 1 output or 2 separate soundcards
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Portaudio ASIO structure conversion help

Post by infratec »

Hm. Ok, I can start the code and after some changes at the devices I get a running code without errors.

So what should I do to see the problem with the array?
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Portaudio ASIO structure conversion help

Post by AndyMK »

follow these steps;
1. installhttps://vb-audio.com/Cable/index.htm
2. They are virtual audio device drivers. Once installed, make sure the windows default audio input/output are these devices.
3. In the code, op2\device should be CABLE-OUTPUT device number
4. In the code, op\device should be your ASIO output device

You should get sound coming out of you ASIO device when playing youtube or some other windows app.
If your ASIO device has more than 1 stereo output, try making the code output to the other outputs.
May the force be with you
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Portaudio ASIO structure conversion help

Post by AndyMK »

This works using the C backend.

Code: Select all

ImportC "portaudio_x64.lib" : EndImport 
!//#include D:\Purebasic\portaudio\portaudio.h;  
!//#include D:\Purebasic\portaudio\pa_asio.h;  

!#define SAMPLE_RATE         (48000)
!#define PA_SAMPLE_TYPE      paFloat32
!#define FRAMES_PER_BUFFER   (16384/8)
!typedef float SAMPLE;

!/* Non-linear amplifier With soft distortion curve. */

Global err,pcb, mutex = CreateMutex(), buffersize = 16384
*buffer = AllocateMemory(16384)

Procedure Error(err)
  !v_error = Pa_GetErrorText(v_err);
  MessageRequester("", PeekS(error, -1, #PB_Ascii))
  End
EndProcedure


ProcedureCDLL PaStreamCallback1(*in, *output, framesPerBuffer, *timeInfo, statusFlags, *userData)
  
  LockMutex(mutex)
  CopyMemory(*userData, *output, buffersize)
  UnlockMutex(mutex)
  
EndProcedure

ProcedureCDLL PaStreamCallback2(*in, *output, framesPerBuffer, *timeInfo, statusFlags, *userData)
  
  LockMutex(mutex)
  CopyMemory(*in, *userData, buffersize)
  UnlockMutex(mutex)
  
EndProcedure

!int outputChannelSelectors[1];
!PaAsioStreamInfo asioOutputInfo;
!PaStreamParameters inputParameters, outputParameters;
!PaStream *stream1, *stream2;

pcb1 = @PaStreamCallback1()
pcb2 = @PaStreamCallback2()
!v_err = Pa_Initialize();
If err <> 0
  Error(err)
EndIf  

!inputParameters.device = 4; /* default input device */
!if (inputParameters.device == paNoDevice) {
Debug "Error: No default input device."
;Goto error;
!}
!inputParameters.channelCount = 2;       /* stereo input */
!inputParameters.sampleFormat = paFloat32;
!inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
!inputParameters.hostApiSpecificStreamInfo = 0;

!outputParameters.device = 1; /* default output device */
!if (outputParameters.device == paNoDevice) {
Debug "Error: No Default output device.\n"
;Goto error;
!}
!outputParameters.channelCount = 2;       /* stereo output */
!outputParameters.sampleFormat = paFloat32;
!outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;

!asioOutputInfo.size = sizeof(PaAsioStreamInfo);
!asioOutputInfo.hostApiType = paASIO           ;
!asioOutputInfo.version = 1                    ;
!asioOutputInfo.flags = paAsioUseChannelSelectors;
!outputChannelSelectors[0] = 4;                   
!outputChannelSelectors[1] = 5; 
!asioOutputInfo.channelSelectors = outputChannelSelectors;

!outputParameters.hostApiSpecificStreamInfo = &asioOutputInfo;


!v_err = Pa_OpenStream(&stream1,0,&outputParameters,SAMPLE_RATE,FRAMES_PER_BUFFER,0,v_pcb1,p_buffer );
If err <> 0
  Error(err)
EndIf 

!v_err = Pa_OpenStream(&stream2,&inputParameters,0,SAMPLE_RATE,FRAMES_PER_BUFFER,0,v_pcb2,p_buffer );
If err <> 0
  Error(err)
EndIf 

!v_err = Pa_StartStream( stream1 );
If err <> 0
  Error(err)
EndIf 

!v_err = Pa_StartStream( stream2 );
If err <> 0
  Error(err)
EndIf 

Repeat
  Delay(1)
ForEver

!v_err = Pa_CloseStream( stream1 );
If err <> 0
  Error(err)
EndIf 

!Pa_Terminate();

error:
!Pa_Terminate();
User avatar
idle
Always Here
Always Here
Posts: 5097
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Portaudio ASIO structure conversion help

Post by idle »

Code: Select all

!int outputChannelSelectors[1];
!outputChannelSelectors[0] = 4;                   
!outputChannelSelectors[1] = 5; 
!asioOutputInfo.channelSelectors = outputChannelSelectors;
This looks like its doing copy by value rather than by reference or you'd see &outputChannelSelectors.
how is channelSelectors defined

this could work perhaps

Code: Select all

outputChannelSelectors.q
outputChannelSelectors = 4;                   
outputChannelSelectors | 5 << 32; 

;and if you need to access it you can do it like this or with mask
Structure arL 
  el.l[0] 
EndStructure   

*p.arL = @outputChannelSelectors
Debug *p\el[0] 
Debug *p\el[1]

AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Portaudio ASIO structure conversion help

Post by AndyMK »

@idle

Does not work. Is there a disadvantage to using the C backend with inline C? I find its much easier to get up and running. No converting headers and importing functions
User avatar
idle
Always Here
Always Here
Posts: 5097
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Portaudio ASIO structure conversion help

Post by idle »

No disadvantage at all except you need the comand line compiler tool and that's still waiting for an osx person to make it work.

And yes it's a lot easier to use a c library with inline c.
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Portaudio ASIO structure conversion help

Post by infratec »

I forgot to post my test code.
I also modified some structures and imports.

Code: Select all

Enumeration ;PaErrorCode
  #paNoError = 0
  #paNotInitialized = -10000
  #paUnanticipatedHostError
  #paInvalidChannelCount
  #paInvalidSampleRate
  #paInvalidDevice
  #paInvalidFlag
  #paSampleFormatNotSupported
  #paBadIODeviceCombination
  #paInsufficientMemory
  #paBufferTooBig
  #paBufferTooSmall
  #paNullCallback
  #paBadStreamPtr
  #paTimedOut
  #paInternalError
  #paDeviceUnavailable
  #paIncompatibleHostApiSpecificStreamInfo
  #paStreamIsStopped
  #paStreamIsNotStopped
  #paInputOverflowed
  #paOutputUnderflowed
  #paHostApiNotFound
  #paInvalidHostApi
  #paCanNotReadFromACallbackStream      ;/**< @todo review error code name */
  #paCanNotWriteToACallbackStream       ;/**< @todo review error code name */
  #paCanNotReadFromAnOutputOnlyStream   ;/**< @todo review error code name */
  #paCanNotWriteToAnInputOnlyStream     ;/**< @todo review error code name */
  #paIncompatibleStreamHostApi
  #paBadBufferPtr
EndEnumeration

#paNoDevice = (-1)
#paUseHostApiSpecificDeviceSpecification = (-2)

Enumeration ;PaHostApiTypeId
  #paInDevelopment = 0 ; /* use while developing support for a new host API */
  #paDirectSound = 1
  #paMME = 2
  #paASIO = 3
  #paSoundManager = 4
  #paCoreAudio = 5
  #paOSS = 7
  #paALSA = 8
  #paAL = 9
  #paBeOS = 10
  #paWDMKS = 11
  #paJACK = 12
  #paWASAPI = 13
  #paAudioScienceHPI = 14
EndEnumeration

#paFloat32        = ($00000001)
#paInt32          = ($00000002)
#paInt24          = ($00000004)
#paInt16          = ($00000008)
#paInt8           = ($00000010)
#paUInt8          = ($00000020)
#paCustomFormat   = ($00010000)
#paNonInterleaved = ($80000000)

#paFormatIsSupported = (0)
#paFramesPerBufferUnspecified = (0)
#paNoFlag          = (0)
#paClipOff         = ($00000001)
#paDitherOff       = ($00000002)
#paNeverDropInput  = ($00000004)
#paPrimeOutputBuffersUsingStreamCallback = ($00000008)
#paPlatformSpecificFlags = ($FFFF0000)

#paInputUnderflow   = ($00000001)
#paInputOverflow    = ($00000002)
#paOutputUnderflow  = ($00000004)
#paOutputOverflow   = ($00000008)
#paPrimingOutput    = ($00000010)

Enumeration ; PaStreamCallbackResult
  #paContinue=0
  #paComplete=1
  #paAbort=2
EndEnumeration

Structure PaHostApiInfo Align #PB_Structure_AlignC
  structVersion.l
  type.l
  *name
  deviceCount.l
  defaultInputDevice.l
  defaultOutputDevice.l
EndStructure

Structure PaHostErrorInfo Align #PB_Structure_AlignC
  hostApiType.l   
  errorCode.l            
  errorText.s
EndStructure

Structure PaDeviceInfo Align #PB_Structure_AlignC
  structVersion.l
  *name
  hostApi.l
  maxInputChannels.l
  maxOutputChannels.l
  defaultLowInputLatency.d
  defaultLowOutputLatency.d
  defaultHighInputLatency.d
  defaultHighOutputLatency.d
  defaultSampleRate.d
EndStructure

Structure PaStreamParameters Align #PB_Structure_AlignC
  device.l ; 4 bytes
  channelCount.l ; 4 bytes
  sampleFormat.l ; 4 bytes
  suggestedLatency.d ; 8 bytes
  pad1.l
  *hostApiSpecificStreamInfo
  pad2.l
  ;PORTAUDIO ***MUST*** BE COMPILED WITH STRUCTURE ALIGNMENT = 4
EndStructure

Structure PaStreamCallbackTimeInfo Align #PB_Structure_AlignC
  inputBufferAdcTime.d
  currentTime.d
  outputBufferDacTime.d
EndStructure

Structure PaStreamInfo Align #PB_Structure_AlignC
  structVersion.l
  inputLatency.d
  outputLatency.d
  sampleRate.d
EndStructure

;PrototypeC PaStreamCallback(*input, *output, frameCount.l, *timeInfo, statusFlags, *userdata)
;PrototypeC PaStreamFinishedCallback(*user_data)

;Setup flags
#paWinWasapiExclusive                = 1 << 0 ;puts WASAPI into exclusive mode
#paWinWasapiRedirectHostProcessor    = 1 << 1 ;allows To skip internal PA processing completely
#paWinWasapiUseChannelMask           = 1 << 2 ;assigns custom channel mask
#paWinWasapiPolling                  = 1 << 3 ;selects non-Event driven method of
#paWinWasapiThreadPriority           = 1 << 4 ;forces custom thread priority setting.

;Device role
Enumeration PaWasapiDeviceRole
  #eRoleRemoteNetworkDevice = 0
  #eRoleSpeakers
  #eRoleLineLevel
  #eRoleHeadphones
  #eRoleMicrophone
  #eRoleHeadset
  #eRoleHandset
  #eRoleUnknownDigitalPassthrough
  #eRoleSPDIF
  #eRoleHDMI
  #eRoleUnknownFormFactor
EndEnumeration

;Jack connection type
;PaWasapiJackConnectionType.l ;???
Enumeration PaWasapiJackConnectionType
  #eJackConnTypeUnknown
  #eJackConnType3Point5mm
  #eJackConnTypeQuarter
  #eJackConnTypeAtapiInternal
  #eJackConnTypeRCA
  #eJackConnTypeOptical
  #eJackConnTypeOtherDigital
  #eJackConnTypeOtherAnalog
  #eJackConnTypeMultichannelAnalogDIN
  #eJackConnTypeXlrProfessional
  #eJackConnTypeRJ11Modem
  #eJackConnTypeCombination
EndEnumeration

;Jack geometric location
;PaWasapiJackGeoLocation.l ;???
Enumeration PaWasapiJackGeoLocation
  #eJackGeoLocUnk = 0
  #eJackGeoLocRear = 1 ;matches EPcxGeoLocation::eGeoLocRear */
  #eJackGeoLocFront
  #eJackGeoLocLeft
  #eJackGeoLocRight
  #eJackGeoLocTop
  #eJackGeoLocBottom
  #eJackGeoLocRearPanel
  #eJackGeoLocRiser
  #eJackGeoLocInsideMobileLid
  #eJackGeoLocDrivebay
  #eJackGeoLocHDMI
  #eJackGeoLocOutsideMobileLid
  #eJackGeoLocATAPI
  #eJackGeoLocReserved5
  #eJackGeoLocReserved6
EndEnumeration

;Jack general location
;PaWasapiJackGenLocation.l ;???
Enumeration PaWasapiJackGenLocation
  #eJackGenLocPrimaryBox = 0
  #eJackGenLocInternal
  #eJackGenLocSeparate
  #eJackGenLocOther
EndEnumeration

;Jack type of port
;PaWasapiJackPortConnection.l ;???
Enumeration PaWasapiJackPortConnection
  #eJackPortConnJack = 0
  #eJackPortConnIntegratedDevice
  #eJackPortConnBothIntegratedAndJack
  #eJackPortConnUnknown
EndEnumeration

Enumeration ;Thread priority
  #eThreadPriorityNone = 0
  #eThreadPriorityAudio ;Default For Shared mode.
  #eThreadPriorityCapture
  #eThreadPriorityDistribution
  #eThreadPriorityGames
  #eThreadPriorityPlayback
  #eThreadPriorityProAudio ;Default For Exclusive mode
  #eThreadPriorityWindowManager
EndEnumeration

;Stream descriptor
Structure PaWasapiStreamInfo Align #PB_Structure_AlignC
  size.l ;SizeOf(PaWasapiStreamInfo)
  hostApiType.l ;#paWASAPI   ;PaHostApiTypeId hostApiType;    ;paWASAPI
  version.l     ;1
  flags.l       ;collection of PaWasapiFlags
  channelMask.l
  hostProcessorOutput.l
  hostProcessorInput.l
  threadPriority.l
  streamCategory.l
  streamOption.l
EndStructure ;End of Structure PaWasapiStreamInfo

Enumeration PaWasapiStreamCategory
  #eAudioCategoryOther           = 0
  #eAudioCategoryCommunications  = 3
  #eAudioCategoryAlerts          = 4
  #eAudioCategorySoundEffects    = 5
  #eAudioCategoryGameEffects     = 6
  #eAudioCategoryGameMedia       = 7
  #eAudioCategoryGameChat        = 8
  #eAudioCategorySpeech          = 9
  #eAudioCategoryMovie           = 10
  #eAudioCategoryMedia           = 11
EndEnumeration

Enumeration ;PaWasapiStreamOption
  #eStreamOptionNone        = 0 ;default
  #eStreamOptionRaw         = 1 ;bypass WASAPI Audio Engine DSP effects, supported since Windows 8.1
  #eStreamOptionMatchFormat = 2 ;force WASAPI Audio Engine into a stream format, supported since Windows 10
EndEnumeration

#paAsioUseChannelSelectors      = $01

;Stream descriptor
Structure PaWasapiJackDescription Align #PB_Structure_AlignC
  channelMapping.l
  color.l ;derived from macro: #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) */
  connectionType.l
  geoLocation.l
  genLocation.l
  portConnection.l
  isConnected.l
EndStructure

Structure PaAsioStreamInfo Align #PB_Structure_AlignC
  size.l
  hostApiType.l
  version.l
  flags.l
  *channelSelectors
EndStructure

ImportC "portaudio_x64.lib"
  Pa_GetVersion()
  Pa_GetVersionText()
  Pa_GetErrorText(errorCode.l)
  Pa_Initialize()
  Pa_Terminate()
  Pa_GetHostApiCount()
  Pa_GetDefaultHostApi()
  Pa_GetHostApiInfo(hostApi.l)
  Pa_HostApiTypeIdToHostApiIndex(type.l)
  Pa_HostApiDeviceIndexToDeviceIndex(hostApi.l, hostApiDeviceIndex.l)
  Pa_GetLastHostErrorInfo()
  Pa_GetDeviceCount()
  Pa_GetDefaultInputDevice()
  Pa_GetDefaultOutputDevice()
  Pa_GetDeviceInfo(device.l)
  Pa_IsFormatSupported(*inputParameters, *outputParameters, sampleRate.d)
  Pa_OpenStream(*stream, *inputParameters, *outputParameters, sampleRate.d, framesPerBuffer, streamFlags, *streamCallback, *user_data)
  Pa_OpenDefaultStream(*stream, numInputChannels.l, numOutputChannels.l, sampleFormat.l, sampleRate.d, framesPerBuffer.l, *streamCallback, *user_data)
  Pa_CloseStream(*stream)
  Pa_SetStreamFinishedCallback(*stream, *streamFinishedCallback)
  Pa_StartStream(*stream)
  Pa_StopStream(*stream)
  Pa_AbortStream(*stream)
  Pa_IsStreamStopped(*stream)
  Pa_IsStreamActive(*stream)
  Pa_GetStreamInfo(*stream)
  Pa_GetStreamTime.d(*stream)
  Pa_GetStreamCpuLoad.d(*stream)
  Pa_ReadStream(*stream, *buffer, frames.l)
  Pa_WriteStream(*stream, *buffer, frames.l)
  Pa_GetStreamReadAvailable(*stream)
  Pa_GetStreamWriteAvailable(*stream)
  Pa_GetSampleSize(format.l)
  Pa_Sleep(msec.l)
  PaWasapi_GetDeviceDefaultFormat(*pFormat, nFormatSize.l, nDevice.l)
  PaWasapi_GetDeviceRole(nDevice.l)
  PaWasapi_ThreadPriorityBoost(*hTask, nPriorityClass.l)
  PaWasapi_ThreadPriorityRevert(*hTask)
  PaWasapi_GetFramesPerHostBuffer(*pStream, *nInput, *nOutput)
  PaWasapi_GetJackCount(nDevice.l, *jcount);
  PaWasapi_GetJackDescription(nDevice.l, jindex.l, *pJackDescription)
  PaAsio_GetAvailableBufferSizes(device.l, *minBufferSizeFrames, *maxBufferSizeFrames, *preferredBufferSizeFrames, *granularity)
  PaAsio_ShowControlPanel(device.l, *systemSpecific)
EndImport

Global buffersize = 16384, mutex = CreateMutex(), *outputStream, *inputStream

*buffer = AllocateMemory(buffersize)

Procedure Error(err)
  
  Debug Pa_GetErrorText(err)
  Debug PeekS(Pa_GetErrorText(err), -1, #PB_Ascii)
  ;MessageRequester("", PeekS(Pa_GetErrorText(err), -1, #PB_Ascii))
  End
  
EndProcedure

ProcedureC.l outputStreamCallback(*in, *output, frameCount.l, *timeInfo.PaStreamCallbackTimeInfo, statusFlags.l, *userData)
  
  LockMutex(mutex)
  CopyMemory(*userData, *output, buffersize)
  UnlockMutex(mutex)
  
  ProcedureReturn #paContinue
  
EndProcedure

ProcedureC.l inputStreamCallback(*in, *output, frameCount.l, *timeInfo.PaStreamCallbackTimeInfo, statusFlags.l, *userData)
  
  LockMutex(mutex)
  CopyMemory(*in, *userData, buffersize)
  UnlockMutex(mutex)
  
  ProcedureReturn #paContinue
  
EndProcedure

Pa_Initialize()

*my_dev.PaDeviceInfo

For d_count = 0 To Pa_GetDeviceCount() - 1
  *my_dev = Pa_GetDeviceInfo(d_count)
  Debug Str(d_count) + " " + PeekS(*my_dev\name, -1, #PB_Ascii)
  ;   Debug *my_dev\hostApi
  ;   Debug *my_dev\maxInputChannels
  ;   Debug *my_dev\maxOutputChannels
  ;   Debug *my_dev\defaultLowInputLatency
  ;   Debug *my_dev\defaultLowOutputLatency
  ;   Debug *my_dev\defaultHighInputLatency
  ;   Debug *my_dev\defaultHighOutputLatency
  ;   Debug *my_dev\defaultSampleRate
Next

; Audio Output Setup
Define outputStreamParameters.PaStreamParameters
outputStreamParameters\channelCount = 2
outputStreamParameters\device = 0 ;<---- ASIO Soundcard output device
outputStreamParameters\sampleFormat = #paFloat32

Dim outputchannelselectors.l(1)
outputchannelselectors(0) = 2 ;<--------- use outputs 2L
outputchannelselectors(1) = 3 ;<--------- use outputs 3R

Define asio_info.PaAsioStreamInfo
asio_info\size = SizeOf(asio_info)
asio_info\hostApiType = #paASIO
asio_info\version = 0
asio_info\flags = #paAsioUseChannelSelectors
asio_info\channelSelectors = outputchannelselectors

outputStreamParameters\hostApiSpecificStreamInfo = @asio_info

err = Pa_OpenStream(@*outputStream, #Null, @outputStreamParameters, 48000, buffersize/8, #paNoFlag, @outputStreamCallback(), *buffer)
err = Pa_StartStream(*outputStream)
If err <> #paNoError
  Error(err)
EndIf

Define inputStreamParameters.PaStreamParameters
inputStreamParameters\channelCount = 1
inputStreamParameters\device = 4 ;<----- WDM soundcard input device
inputStreamParameters\sampleFormat = #paFloat32

err = Pa_OpenStream(@*inputStream, @inputStreamParameters, #Null, 48000, buffersize/8, #paNoFlag, @inputStreamCallback(), *buffer)
err = Pa_StartStream(*inputStream)
If err <> #paNoError
  Error(err)
EndIf

If err <> #paNoError
  Error(err)
EndIf

Repeat
  Delay(1)
ForEver
AndyMK
Enthusiast
Enthusiast
Posts: 540
Joined: Wed Jul 12, 2006 4:38 pm
Location: UK

Re: Portaudio ASIO structure conversion help

Post by AndyMK »

still not working.. but to be honest, with the new C backend and inline C, i prefer it much more and its a good opportunity to learn some C
Post Reply