Re: ATTN: Andrej Mitrovic: Port Audio

2017-08-26 Thread Johnson via Digitalmars-d-learn

On Sunday, 27 August 2017 at 02:23:32 UTC, Johnson wrote:

On Sunday, 27 August 2017 at 02:00:22 UTC, Johnson wrote:
You wrote a thread a while back about your callbacks not being 
called and you had a fix.


[...]


After going through the code a bit, seems there are some bugs 
with  Only OpenStream seems to take a ** so the other 
functions are getting passed junk.


At least, I got sound! Scared the shit out of me too!


I should mention that the callback is still not being called, but 
I used the sawtooth to modify a buffer and used Pa_WriteStream. 
Pa_SetStreamFinishedCallback is working.


PaStreamFlags.PrimeOutputBuffersUsingStreamCallback still causes 
an access violation.


Seems like the callback address is not being correctly 
transmitted to PA.




Re: ATTN: Andrej Mitrovic: Port Audio

2017-08-26 Thread Johnson via Digitalmars-d-learn

On Sunday, 27 August 2017 at 02:00:22 UTC, Johnson wrote:
You wrote a thread a while back about your callbacks not being 
called and you had a fix.


[...]


After going through the code a bit, seems there are some bugs 
with  Only OpenStream seems to take a ** so the other 
functions are getting passed junk.


At least, I got sound! Scared the shit out of me too!


ATTN: Andrej Mitrovic: Port Audio

2017-08-26 Thread Johnson via Digitalmars-d-learn
You wrote a thread a while back about your callbacks not being 
called and you had a fix.


http://www.digitalmars.com/d/archives/digitalmars/D/learn/Anyone_using_Portaudio_22343.html

I'm trying to get portAudio to work on my machine and it seems 
everything passes yet my callbacks are not being called.



I do not know if it is the same issue you had or what. Could you 
describe your fixes, if you remember? You said it was alias 
issues, my source uses alias, so maybe I have the updated one.


Also, using paPrimeOutputBuffersUsingStreamCallback causes an 
access violation ;/


Here are some dll's I'm using

https://github.com/spatialaudio/portaudio-binaries



I'm including the two files needed to compile what I have in case 
you(or anyone else) decide to help figure this out:


Make sure to change the dll location in the DLL_PortAudio struct 
and set the appropriate audio interface to use(I have it set to 
12, but have tried every value on my system with no luck).



module mPortAudio;
import std.stdio, std.conv;


enum PaError : int
{   
NoError = 0,
NotInitialized = -1,
UnanticipatedHostError,
InvalidChannelCount,
InvalidSampleRate,
InvalidDevice,
InvalidFlag,
SampleFormatNotSupported,
BadIODeviceCombination,
InsufficientMemory,
BufferTooBig,
BufferTooSmall,
NullCallback,
BadStreamPtr,
TimedOut,
InternalError,
DeviceUnavailable,
IncompatibleHostApiSpecificStreamInfo,
StreamIsStopped,
StreamIsNotStopped,
InputOverflowed,
OutputUnderflowed,
HostApiNotFound,
InvalidHostApi,
CanNotReadFromACallbackStream,
CanNotWriteToACallbackStream,
CanNotReadFromAnOutputOnlyStream,
CanNotWriteToAnInputOnlyStream,
IncompatibleStreamHostApi,
BadBufferPtr,
FormatIsSupported = 0,
};

enum PaSampleFormat : ulong
{
Float32  = 0x0001,
Int32= 0x0002,
Int24= 0x0004,
Int16= 0x0008,
Int8 = 0x0010,
UInt8= 0x0020,
CustomFormat = 0x0001,
NonInterleaved = 0x8000
}

enum PaHostApiTypeId : int
{
InDevelopment=0,
DirectSound=1,
MME=2,
ASIO=3,
SoundManager=4,
CoreAudio=5,
OSS=7,
ALSA=8,
AL=9,
BeOS=10,
WDMKS=11,
JACK=12,
WASAPI=13,
AudioScienceHPI=14
};


enum PaStreamCallbackResult : int
{
paContinue=0,   /**< Signal that the stream should continue 
invoking the callback and processing audio. */
paComplete=1,   /**< Signal that the stream should stop 
invoking the callback and finish once all output samples have 
played. */
paAbort=2   /**< Signal that the stream should stop 
invoking the callback and finish as soon as possible. */

};





enum PaStreamFlags : ulong
{
NoFlag = 0,
ClipOff = 0x0001,
DitherOff = 0x0002,
NeverDropInput = 0x0004,
PrimeOutputBuffersUsingStreamCallback = 0x0008,
PlatformSpecificFlags = 0x,
}

alias void PaStream;
enum paFramesPerBufferUnspecified = 0;
enum PaStreamCallbackFlags : ulong
{
InputUnderflow = 0x0001,
InputOverflow = 0x0002,
OutputUnderflow = 0x0004,
OutputOverflow = 0x0008,
PrimingOutput = 0x0010,
}



alias extern(C) int function(const(void) *input, void *output, 
ulong frameCount, const(PaStreamCallbackTimeInfo)* timeInfo, 
PaStreamCallbackFlags statusFlags, void *userData ) 
PaStreamCallback;

alias void function( void *userData ) PaStreamFinishedCallback;

alias int PaDeviceIndex;
enum paNoDevice = cast(PaDeviceIndex)-1;
enum paUseHostApiSpecificDeviceSpecification =  
cast(PaDeviceIndex)-2;

alias int PaHostApiIndex;
alias double PaTime;


struct PaHostApiInfo
{
int structVersion;
PaHostApiTypeId type;
const(char) *name;
int deviceCount;
PaDeviceIndex defaultInputDevice;
PaDeviceIndex defaultOutputDevice;
};

struct PaDeviceInfo
{
int structVersion;
const(char) *name;
PaHostApiIndex hostApi;
int maxInputChannels;
int maxOutputChannels;
PaTime defaultLowInputLatency;
PaTime defaultLowOutputLatency;
PaTime defaultHighInputLatency;
PaTime defaultHighOutputLatency;
double defaultSampleRate;
};

struct PaStreamCallbackTimeInfo
{
PaTime inputBufferAdcTime;
PaTime currentTime;
PaTime outputBufferDacTime;
};

struct PaStreamInfo
{
int structVersion;
PaTime inputLatency;
PaTime outputLatency;
double sampleRate;
};


struct PaHostErrorInfo
{
PaHostApiTypeId hostApiType;
long errorCode;
const(char) *errorText;
};

struct PaStreamParameters
{
PaDeviceIndex device;
int channelCount;
PaSampleFormat sampleFormat;
PaTime suggestedLatency;
void *hostApiSpecificStreamInfo;
};
























struct DLL_PortAudio
{
@("DLLImport") public static