David Wilson | 27 Jun 19:53 2015
Picon

Re: Tones not clean (with crackling sound)

I finally figured out the problem with much appreciated help from Eliot. I am posting the solution (playing DTMF tone 1) for anyone else who may encounter the same problem:

Regards,
David

int CSound4::TestDTMF_mono()
{
    const int NUM_SECONDS_ = 1;
    const float SAMPLE_RATE_ = 44100.0;
    const int FRAMES_PER_BUFFER_ = 1024;   

    PaStream *stream = NULL;
    PaError err;
    PaStreamParameters outputParameters;

    float buffer[FRAMES_PER_BUFFER_]={0};

    float f1, f2 = 0.0;
    float amplitude = 1.0;

    f1 = 697.0;
    f2 = 1209.0;

    float phase1 = 0.0;   
    float phase2 = 0.0;   

    float inc1 = (2.0 * M_PI * f1) / SAMPLE_RATE_;
    float inc2 = (2.0 * M_PI * f2) / SAMPLE_RATE_;

    for(long i=0; i < FRAMES_PER_BUFFER_; i++) {

        buffer[i] = amplitude * (sin(phase1) + sin(phase2)) * 0.5;               

        phase1 += inc1;
        phase2 += inc2;
    }   
   
    Pa_Initialize();
   
    outputParameters.device = Pa_GetDefaultOutputDevice();
    if (outputParameters.device == paNoDevice) {
      TRACE("Error: No default output device.\n");
      goto error;
    }

    outputParameters.channelCount = 1;
    outputParameters.sampleFormat = paFloat32;
    outputParameters.suggestedLatency = 0.050;
    outputParameters.hostApiSpecificStreamInfo = NULL;
 
    err = Pa_OpenStream(
               &stream,
               NULL,
               &outputParameters,
               SAMPLE_RATE_,
               FRAMES_PER_BUFFER_,
               paClipOff,       
               NULL,           
               NULL );           

    if( err != paNoError ) goto error;

    err = Pa_StartStream( stream );
    int bufferCount = ((NUM_SECONDS_ * SAMPLE_RATE_) / FRAMES_PER_BUFFER_);  
           
    // play tone
    TRACE("Play sinusoid tone for %f, %f for %d seconds.\n", f1, f2, NUM_SECONDS_);
 
    phase1 = 0.0;   
    phase2 = 0.0;   

    for(int i=0; i < bufferCount; i++ )
    {
        for(int j = 0; j < FRAMES_PER_BUFFER_; j++ )
        {
            buffer[j] = amplitude * (sin(phase1) + sin(phase2)) * 0.5;
           
            phase1 += inc1;
            phase2 += inc2;           
        }
 
        err = Pa_WriteStream( stream, buffer, FRAMES_PER_BUFFER_ );
        if( err != paNoError ) goto error;
    }   
 
    err = Pa_StopStream( stream );
    if( err != paNoError ) goto error;
      
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
     
    return err;
 
 error:
     TRACE( "An error occured while using the portaudio stream\n" );    
     return err;
}
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
David Wilson | 27 Jun 02:26 2015
Picon

Tones not clean (with crackling sound)

Hi All,

I am stuck trying to play the touch tone 1. I can hear the tone (same as what you hear on phone when pressing 1), but it's not clean (I hear some crackling).

Do you guys have any ideas how to fix this? My code is attached (I am not using a callback; just a blocking call to pa).

Thanks very much,
David

int CSound4::TestDTMF()
{
    int NUM_SECONDS_ = 1;
    float SAMPLE_RATE_ = 44100.0;
    int FRAMES_PER_BUFFER_ = 1024;

    PaStream *stream = NULL;
    PaError err;
    PaStreamParameters outputParameters;

    float buffer[FRAMES_PER_BUFFER2]; /* mono */

     // clear buffer
    for(int j=0; j < FRAMES_PER_BUFFER2; j++ )
    {
        buffer[j] = 0;         
    }

    float f1, f2 = 0.0;
    double A, B = 0.0;

    float amplitude = 1.0;

    f1 = 697.0;
    f2 = 1209.0;

    // precalculations
    A=B=2*M_PI/SAMPLE_RATE2;
    A*= f1;
    B*= f2;

    // DTMF tone (sin (i*2 * Pi * f1/sample_rate) + sin(n*2 * Pi * f2/sample_rate)) / 2
    for(long i=0; i < FRAMES_PER_BUFFER_; i++) {
        buffer[i] = amplitude*0.5*(sin(A*(i))+sin(B*(i)));     
    }   
   
    // init. pa
    Pa_Initialize();
   
    outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
    if (outputParameters.device == paNoDevice) {
      TRACE("Error: No default output device.\n");
      goto error;
    }

    outputParameters.channelCount = 1;           
    outputParameters.sampleFormat = paFloat32;
    outputParameters.suggestedLatency = 0.050;
    outputParameters.hostApiSpecificStreamInfo = NULL;
 
    err = Pa_OpenStream(
               &stream,
               NULL,
               &outputParameters,
               SAMPLE_RATE_,
               FRAMES_PER_BUFFER_,
               paClipOff,
               NULL,     /* no callback, use blocking API */
               NULL );   /* no callback, so no callback userData */

    if( err != paNoError ) goto error;

    err = Pa_StartStream( stream );
    int bufferCount = ((NUM_SECONDS_ * SAMPLE_RATE_) / FRAMES_PER_BUFFER_);  
           
    // play tone
    TRACE("Play sinusoid tone for %f, %f for %d seconds.\n", f1, f2, NUM_SECONDS_);
 
    for(int i=0; i < bufferCount; i++ )
    {
        for(int j=0; j < FRAMES_PER_BUFFER_; j++ )
        {           
            buffer[i] = amplitude*0.5*(sin(A*(i))+sin(B*(i)));                    
        }
 
        err = Pa_WriteStream( stream, buffer, FRAMES_PER_BUFFER_ );
        if( err != paNoError ) goto error;
    }  
 
    err = Pa_StopStream( stream );
    if( err != paNoError ) goto error;
      
    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;
     
    return err;
 
 error:
     TRACE( "An error occured while using the portaudio stream\n" );   
     return err;
}
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
My Demos | 22 Jun 04:28 2015
Picon

Re: DTMF Tone generation



Thanks for the suggestions; I am closer thanks to help from Eliot.

I went back to a simple mono example, which finally plays the touch tone 1 (f1=697, f2=1209), but it doesn't sound clean (I hear some crackling). The sin data generated seem correct (I compared it with known and correct data).

I am not sure what I am missing to get a clean touch tone. Any suggestion is greatly appreciated.


typedef struct
{   
    float f1;    // frequency 1
    float f2;    // frequency 2   
} MyData;

#define SAMPLE_RATE 44100

#define PI 3.1415926536  
#define TWO_PI_BY_RATE ((2*PI)/SAMPLE_RATE)

static int paCallback(const void *in, void *out, unsigned long framesPerBuffer,
                    const PaStreamCallbackTimeInfo *timeinfo,
                    PaStreamCallbackFlags statusFlags,
                    void *userdata)
{
    unsigned i;
    float *buf=(float *)out; 
    MyData *data=(MyData *)userdata;

    float factor1 = data->f1 * TWO_PI_BY_RATE;
    float factor2 = data->f2 * TWO_PI_BY_RATE;

    // fill frame with sine waves
    for (i=0;i<framesPerBuffer;i++)
    {
        buf[i] = (sin((float)i*factor1) + sin((float)i*factor2))/2.0;
        //TRACE("i=%d, val=%f\n", i, buf[i]);   
    }

  return paContinue;
}

void handlePaError(int n,int err,char *s)
{
  fprintf(stderr,s,Pa_GetErrorText(err));
  Pa_Terminate();
}

int CSound7::Test()
{
    int err;
    PaStream *stream;
    MyData data;


    err=Pa_Initialize();
    if (err!=paNoError) handlePaError(101,err,"Error initializing PortAudio: %s\n");
 

    // dw: compute length
    //unsigned long framesPerBuffer = (200.0/1000.0) * 44100.0; <- didn't work ???
    unsigned long framesPerBuffer = 0;

    err=Pa_OpenDefaultStream(&stream, 0, 1, paFloat32, 44100.0, framesPerBuffer, paCallback ,&data);
    if (err!=paNoError) handlePaError(102,err,"Error opening audio stream: %s\n");
   
    err=Pa_StartStream(stream);
    if (err!=paNoError) handlePaError(104,err,"Error starting audio stream:  %s\n");

    // play '1'
    data.f1 = 697.0;
    data.f2 = 1209.0;

    Pa_Sleep(200); // play for 200 ms

    // stop
    err=Pa_StopStream(stream);
    if (err!=paNoError) handlePaError(104,err,"Error stopping audio stream:  %s\n");

    err=Pa_CloseStream(stream);
    if (err!=paNoError) handlePaError(105,err,"Error closing audio stream:  %s\n");

    err=Pa_Terminate();
    if (err!=paNoError) handlePaError(103,err,"Error terminating PortAudio: %s\n");
 
    return err;
}





_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
My Demos | 19 Jun 22:04 2015
Picon

Re: DTMF Tone generation

Hi Eliot,

Thanks for the reply. I tried your suggestion, but, I am still not able to hear the dial tone 1 (just like the phone; the sound generated is close to white noise).

Ideally, I would like to be able to play the DTMF tones on both channels. So I took the paex_sine.c (attached) sample that comes with portaudio and tried modifying it; but, still no luck.

float f1 = 697.0;
float f2 = 1209.0;

float w1 = 2.0 * M_PI * f1 / SAMPLE_RATE;
float w2 = 2.0 * M_PI * f2 / SAMPLE_RATE;

float phase1 = 0.0;
float phase2 = 0.0;


/* This routine will be called by the PortAudio engine when audio is needed.
** It may called at interrupt level on some machines so don't do anything
** that could mess up the system like calling malloc() or free().
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
                            unsigned long framesPerBuffer,
                            const PaStreamCallbackTimeInfo* timeInfo,
                            PaStreamCallbackFlags statusFlags,
                            void *userData )
{
    paTestData *data = (paTestData*)userData;
    float *out = (float*)outputBuffer;
    unsigned long i;

    (void) timeInfo; /* Prevent unused variable warnings. */
    (void) statusFlags;
    (void) inputBuffer;   
   
   
    for( i=0; i<framesPerBuffer; i++ )
    {
        //*out++ = data->sine[data->left_phase];  /* left */
        //*out++ = data->sine[data->right_phase];  /* right */

        *out++ = (float)sin(phase1) + (float)sin(phase2) ;
    
        phase1 += w1;
        phase2 += w2;
    }
   
    return paContinue;
}

I appreciate any help in getting this sample to work.

Regards,

David



On Sunday, June 14, 2015 11:21 PM, Eliot Blennerhassett <ewblen <at> gmail.com> wrote:


On 14/06/15 00:54, My Demos wrote:
> Hi All,
>
> I am trying to use portaudio to send DTMF tones. Does any one have any
> examples or suggestions.
> I tried the following (just sending the tone '1'), but, the sound
> produced is not what I expected (not the DTMF tone 1).

Can you be more specific as to how it not what you expected.
Have you looped it back to linein, recorded it using e.g. audacity, and
looked at the waveform?


>
> The basic question is how to send this sample data:
>
> /sample(n) = amplitude * (sin (n*2 * Pi * f1/8000) + sin(n*2 * Pi * f2/8000))/


This is correct, but your implementation has problems.

Your static buffer of mixed sine waves will not have an integral number
of cycles of either frequency.  So you'll get a discontinuity every block.

Easiest (?) to generate on the fly in your callback.
Keep track of each sinewave's phase across callbacks. Something like:

amp = 0.5
fs = 8000 // samplerate
f1 = 697
f2 = 1209

w1 = 2 * pi * f1 / fs;
w2 = 2 * pi * f2 / fs;

phase1 = 0.0 // track phase continously across callbacks.
phase2 = 0.0

callback() {
for for(i = 0 to frames-1) {
  val = sin(phase1) + sin(phase2)
  buffer[i] = val * amp  // mono example
  phase1 += w1
  phase2 += w2

}
}




/**  <at> file paex_sine.c
	 <at> ingroup examples_src
	 <at> brief Play a sine wave for several seconds.
	 <at> author Ross Bencina <rossb <at> audiomulch.com>
     <at> author Phil Burk <philburk <at> softsynth.com>
*/
/*
 * $Id: paex_sine.c 1752 2011-09-08 03:21:55Z philburk $
 *
 * This program uses the PortAudio Portable Audio Library.
 * For more information see: http://www.portaudio.com/
 * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files
 * (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/*
 * The text above constitutes the entire PortAudio license; however, 
 * the PortAudio community also makes the following non-binding requests:
 *
 * Any person wishing to distribute modifications to the Software is
 * requested to send the modifications to the original developer so that
 * they can be incorporated into the canonical version. It is also 
 * requested that these non-binding requests be included along with the 
 * license above.
 */
#include <stdio.h>
#include <math.h>
#include "portaudio.h"

#define NUM_SECONDS   (5)
#define SAMPLE_RATE   (44100)
#define FRAMES_PER_BUFFER  (64)

#ifndef M_PI
#define M_PI  (3.14159265)
#endif

#define TABLE_SIZE   (200)
typedef struct
{
    float sine[TABLE_SIZE];
    int left_phase;
    int right_phase;
    char message[20];
}
paTestData;

/* This routine will be called by the PortAudio engine when audio is needed.
** It may called at interrupt level on some machines so don't do anything
** that could mess up the system like calling malloc() or free().
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
                            unsigned long framesPerBuffer,
                            const PaStreamCallbackTimeInfo* timeInfo,
                            PaStreamCallbackFlags statusFlags,
                            void *userData )
{
    paTestData *data = (paTestData*)userData;
    float *out = (float*)outputBuffer;
    unsigned long i;

    (void) timeInfo; /* Prevent unused variable warnings. */
    (void) statusFlags;
    (void) inputBuffer;

    for( i=0; i<framesPerBuffer; i++ )
    {
        *out++ = data->sine[data->left_phase];  /* left */
        *out++ = data->sine[data->right_phase];  /* right */
        data->left_phase += 1;
        if( data->left_phase >= TABLE_SIZE ) data->left_phase -= TABLE_SIZE;
        data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
        if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
    }

    return paContinue;
}

/*
 * This routine is called by portaudio when playback is done.
 */
static void StreamFinished( void* userData )
{
   paTestData *data = (paTestData *) userData;
   printf( "Stream Completed: %s\n", data->message );
}

/*******************************************************************/
int main(void);
int main(void)
{
    PaStreamParameters outputParameters;
    PaStream *stream;
    PaError err;
    paTestData data;
    int i;

    
    printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);

    /* initialise sinusoidal wavetable */
    for( i=0; i<TABLE_SIZE; i++ )
    {
        data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
    }
    data.left_phase = data.right_phase = 0;

    err = Pa_Initialize();
    if( err != paNoError ) goto error;

    outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
    if (outputParameters.device == paNoDevice) {
      fprintf(stderr,"Error: No default output device.\n");
      goto error;
    }
    outputParameters.channelCount = 2;       /* stereo output */
    outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
    outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
    outputParameters.hostApiSpecificStreamInfo = NULL;

    err = Pa_OpenStream(
              &stream,
              NULL, /* no input */
              &outputParameters,
              SAMPLE_RATE,
              FRAMES_PER_BUFFER,
              paClipOff,      /* we won't output out of range samples so don't bother clipping them */
              patestCallback,
              &data );
    if( err != paNoError ) goto error;

    sprintf( data.message, "No Message" );
    err = Pa_SetStreamFinishedCallback( stream, &StreamFinished );
    if( err != paNoError ) goto error;

    err = Pa_StartStream( stream );
    if( err != paNoError ) goto error;

    printf("Play for %d seconds.\n", NUM_SECONDS );
    Pa_Sleep( NUM_SECONDS * 1000 );

    err = Pa_StopStream( stream );
    if( err != paNoError ) goto error;

    err = Pa_CloseStream( stream );
    if( err != paNoError ) goto error;

    Pa_Terminate();
    printf("Test finished.\n");

    return err;
error:
    Pa_Terminate();
    fprintf( stderr, "An error occured while using the portaudio stream\n" );
    fprintf( stderr, "Error number: %d\n", err );
    fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
    return err;
}
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
marcas756 | 18 Jun 20:27 2015
Picon

paComplete vs. paAbort

Hello,

I got stuck in an initial test for my portaudio stream.

I prepared a buffer with 25548 samples, and I would like to play it to
completion.
framesPerBuffer is set to 48000 samples  <at>  48kHz -> 1s output buffer.
So I would expect to hear around 1/2 second streaming, but it sounds
like, that portaudio only plays the first few samples and the aborts
playing.

My assumption now is, that paComplete prevents the output buffer to be
played to completion.

So I removed "return paComplete;" in my callback. Now the stream is
played correctly in a loop, as the stream gets not completed now.
I got an endless loop in main to prevent program completion, just for
testing.

PortAudio doc states:
"Another way to stop the stream is to return either paComplete, or
paAbort from your callback. paComplete ensures that the last buffer is
played whereas paAbort stops the stream as soon as possible."

I thought, paComplete causes portaudio to play remaining output buffer
before stopping the stream, but this does not seem to be the case.

Am I getting something wrong here?

My callback function handles the samples in following way:

1.a.) As long as there are more samples available than fit into the
output buffer, copy a complete chunk of samples into the output buffer
1.b.) If the amount of remaining samples exactly fit into the output
buffer, copy the last complete chunk of samples into the output buffer
2.) If there are less samples available than fit into the output buffer,
prefill the output buffer with silence, and copy the remaining samples
into output buffer
3.) If there are no samples available anymore, quit streaming with
paComplete

The stream control data is

typedef struct {
    cr120_sample_t* buffer;      // pointer to buffer with samples
    size_t size;                           // number of samples in
sample buffer                      
    size_t count;                        // forwarded samples (to
portaudio output)
}samplebuffer_t;

static int PaOutputCallback( const void *inputBuffer, void *outputBuffer,
                            unsigned long framesPerBuffer,
                            const PaStreamCallbackTimeInfo* timeInfo,
                            PaStreamCallbackFlags statusFlags,
                            void *userData )
{
    samplebuffer_t *samplebuffer  = (samplebuffer_t *)userData;
    cr120_sample_t *out = (cr120_sample_t *)outputBuffer;

    /* larger or equal size */
    if((samplebuffer->size-samplebuffer-≥count) >= framesPerBuffer)
    {

memcpy(out,&samplebuffer->buffer[samplebuffer->count],framesPerBuffer*sizeof(cr120_sample_t));
        samplebuffer->count+=framesPerBuffer;
    }
    /* smaller size */
    else if ((samplebuffer->size-samplebuffer-≥count) != 0)
    {
        memset(out,CR120_SAMPLE_GND,framesPerBuffer);

memcpy(out,&samplebuffer->buffer[samplebuffer->count],(samplebuffer->size-samplebuffer-≥count)*sizeof(cr120_sample_t));
        samplebuffer->count = samplebuffer->size;
    }
    /* no samples left */
    else
    {
        return paComplete;
    }

    return paContinue;
}

Regards marcas
Bjorn Roche | 16 Jun 22:02 2015

Fwd: Building PortAudio on MAC Mavericks

Hey Paz,

I looked through the logs -- thanks for sending them, and thanks to Phil for approving the large email.

Usually the first error is the one you want to look at because after the first error, problems can cascade. In this case, the first error is

In file included from src/hostapi/coreaudio/pa_mac_core.c:65:

src/hostapi/coreaudio/pa_mac_core_internal.h:64:33: error: CoreAudio/CoreAudio.h: No such file or directory


This tells me that the core audio header file is either missing or not found. You say you have developer tools installed, but they might be out of date. For some reason, however, our build can't find this header. I don't know why, but I'm guessing either:


1. your developer tools are corrupt or incomplete (out of date developer tools installation would probably not cause this error.)

or 

2. you installed the developer tools in a location other than the default and PortAudio can't handle that.


I don't know if port audio can handle installations in a location other than the default location. I would be surprised if you're the first to experience this, but not shocked.


My suggestions:


- uninstall and reinstall developer tools into the default location. I've never uninstalled the developer tools before, so I don't even know if that's possible, but perhaps you can ask on StackOverflow.

- Move the developer tools from wherever they are to the default location. I've never done this either, so I would ask on stack overflow.

- Fix the config file so it works with the developer tools in a location other than the default. I don't know what's involved in this or if this is even a possible problem. Anyone else know? If it is the problem, a fix would be MUCH appreciated!


Sorry I can't be any more constructive, but I hope that helps,


bjorn


<original message not copied due to length>



--
Bjorn Roche
<at> shimmeoapp
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
My Demos | 14 Jun 16:53 2015
Picon

Playing DTMF tones...

Hi All,

I am trying to use portaudio to send DTMF tones, which requires two frequencies (f1 & f2). Does any one have any examples or suggestions?

The basic question is how to send this sample data:

sample(n) = amplitude * (sin (n*2 * Pi * f1/8000) + sin(n*2 * Pi * f2/8000))
Sending data with one sin call (i.e. one frequency) is not a problem; but, I am not sure how to generated the data using from two frequencies (ex: f1=697 and f2=1209).

I appreciate any help (I tried several ways to generate the data but the sound produced is not what's expected).

Thanks very much,
David

_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Paz Offer | 13 Jun 21:35 2015
Picon

Building PortAudio on MAC Mavericks

Hi,

Is it possible to build the latest stable version from PortAudio (v19 20140130) on OS-X 10.9 - MAC Maverick?

I am new to both MAC and PortAudio, but did follow all instructions here and received many errors during the build, some of them are very basic (for example - file 'assert.h' was not found). My assumption is that MAC SDK version might be different from what PA is expecting?

I prefer to be able to build PA on the MAC, but if this is too tricky then copying the output binaries for the MAC - both x86 and x64 - and the header file(s) from somewhere could also be a solution.

Many thanks for any tip, PazO
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
My Demos | 13 Jun 14:54 2015
Picon

DTMF Tone generation

Hi All,

I am trying to use portaudio to send DTMF tones. Does any one have any examples or suggestions.
I tried the following (just sending the tone '1'), but, the sound produced is not what I expected (not the DTMF tone 1).

The basic question is how to send this sample data:

sample(n) = amplitude * (sin (n*2 * Pi * f1/8000) + sin(n*2 * Pi * f2/8000))

I appreciate any help.

Thanks very much,
David


-- code I tried --
PaStreamParameters outputParameters; outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */ if (outputParameters.device == paNoDevice) { TRACE("Error: No default output device.\n"); return; } outputParameters.channelCount = 2; /* stereo output */ outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */ outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; // initialise sinusoidal wavetable MyData data; //int FREQUENCY = 378; //data.amplitude = 0.5; data.amplitude = 1; float lowFrequency = 697.; float highFrequency = 1209.; float PI_PROD_1 = (2.0 * PI * lowFrequency) / SAMPLE_RATE; float PI_PROD_2 = (2.0 * PI * highFrequency) / SAMPLE_RATE; for(int i=0; i < BUFFER_SIZE; i++ ) { //data.sine[i] = (float) sin( (i * 2. * PI * FREQUENCY / (double)BUFFER_SIZE) ); data.sine[i] = 128. + 63. * (float) sin( (i * 2. * PI * highFrequency / (double)BUFFER_SIZE) ) + 63. * (float) sin( (i * 2. * PI * lowFrequency / (double)BUFFER_SIZE) ); } data.left_phase = 0; data.right_phase = 0; // PaStream *stream = NULL; PaError err = Pa_OpenStream( &stream, NULL, /* no input */ &outputParameters, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff, /* we won't output out of range samples so don't bother clipping them */ MyCallback, &data ); if( err != paNoError ) { AfxMessageBox(CString(Pa_GetErrorText( err )), MB_OK); return; } ... } static int MyCallback( const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData ) { MyData *data = (MyData*)userData; float *out = (float*)outputBuffer; unsigned long i = 0; (void) timeInfo; /* Prevent unused variable warnings. */ (void) statusFlags; (void) inputBuffer; for(i = 0; i < framesPerBuffer; i++) { *out++ = data->sine[data->left_phase]; // left *out++ = data->sine[data->right_phase]; // right data->left_phase += 1; if( data->left_phase >= BUFFER_SIZE ) { data->left_phase -= BUFFER_SIZE; } data->right_phase += 3; // higher pitch so we can distinguish left and right. if( data->right_phase >= BUFFER_SIZE ) { data->right_phase -= BUFFER_SIZE; } } return paContinue; }

_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Matthias Geier | 12 Jun 11:16 2015
Picon

Cross-compiling with MXE using wasapi and wdmks?

Dear list.

I've already asked this on the MXE mailing list, but I didn't get an answer:
http://lists.gnu.org/archive/html/mingw-cross-env-list/2015-05/msg00012.html

I'm hoping that someone of you uses MXE an can help me with this ...

Does anyone on this list use MXE to compile PortAudio?

I can successfully cross-compile PortAudio with the default settings
given in https://github.com/mxe/mxe/blob/master/src/portaudio.mk.

However, if I try to enable wasapi and/or wdmks (by just adding it to
the above-mentioned portaudio.mk), the build fails.

Any hints how I can get this to work?

If necessary, I can provide the full output of the compilation process.

cheers,
Matthias
Glenn Ramsey | 11 Jun 23:33 2015
Picon

How to view tickets?

Hi,

When I attempt to view a ticket at

https://www.assembla.com/spaces/portaudio/tickets

I get the message "You don't have access to this ticket".

Do I need an account just to see the tickets or is this a misconfiguration?

Glenn

Gmane