Hi, Try using 48 kHz sampling rate instead of 44.1 kHz (or the other way). AFAIK the HDA Intel is an integrated soundcard, it might have a low quality sample rate converter / interpolator.
Regards, Gabor Pap On Tue, Apr 26, 2011 at 11:55 PM, <eu...@lavabit.com> wrote: > Thanks for the quick response. > > #1 Output format is paFloat32; I also tried initially with paInt16 and a > sine wavetable, and the result was almost identical. > > #2, #3 I've just tried using doubles, and replacing data->amplitude with > 0.1, and the result is identical, data->amplitude[0],[1] was constant > anyway. > > The output device is default, I also printed some initialization details: > > Initializing PortAudio V19-devel (built Apr 17 2011 22:00:29) > ALSA lib pcm.c:2190:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear > ALSA lib pcm.c:2190:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe > ALSA lib pcm.c:2190:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side > ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only > playback stream > Querying devices -- 12 devices found: > 0 - HDA Intel: ALC880 Analog (hw:0,0): > DefaultSR:44100.00 ; MaxInChannels:2 ; MaxOutChannels:2 > 1 - HDA Intel: ALC880 Analog (hw:0,2): > DefaultSR:44100.00 ; MaxInChannels:2 ; MaxOutChannels:0 > 2 - HDA Intel: Si3054 Modem (hw:0,6): > DefaultSR:16000.00 ; MaxInChannels:1 ; MaxOutChannels:1 > 3 - front: > DefaultSR:44100.00 ; MaxInChannels:0 ; MaxOutChannels:2 > 4 - surround40: > DefaultSR:44100.00 ; MaxInChannels:0 ; MaxOutChannels:2 > 5 - surround51: > DefaultSR:44100.00 ; MaxInChannels:0 ; MaxOutChannels:2 > 6 - surround71: > DefaultSR:44100.00 ; MaxInChannels:0 ; MaxOutChannels:2 > 7 - modem: > DefaultSR:16000.00 ; MaxInChannels:1 ; MaxOutChannels:1 > 8 - phoneline: > DefaultSR:16000.00 ; MaxInChannels:1 ; MaxOutChannels:1 > 9 - default: > DefaultSR:44100.00 ; MaxInChannels:128 ; MaxOutChannels:128 > 10 - dmix: > DefaultSR:48000.00 ; MaxInChannels:0 ; MaxOutChannels:2 > 11 - /dev/dsp: > DefaultSR:44100.00 ; MaxInChannels:16 ; MaxOutChannels:16 > Testing if format is supported on device 9: OK > Open output stream on device 9: OK > Start stream: OK > q > Stop stream: OK > Close stream: OK > Terminate portaudio: OK > > Platform is Linux 2.6.32 > The spectrum is strange, looks a bit like aliasing + sidebands... > > Thanks again > > > >> oh also, it *might* matter what device you are using with port audio. >> >> for instance, when i use ASIO i seem to get a much louder, more raw >> signal than if i use, say, the directsound interface. >> >> i think the DS device must do some kind of dsp on it like maybe >> there's a compressor or something. >> >> To rule this out, what you can do is write your output to a file >> instead of (or in addition to) spitting it out to the speaker, then >> run your analysis on the sound file. >> >> Libsndfile is a nice, simple library for reading/writing sound files: >> >> http://www.mega-nerd.com/libsndfile/ >> >> On Tue, Apr 26, 2011 at 1:14 PM, Alan Wolfe <alan.wo...@gmail.com> wrote: >>> just stabbing in the dark in case nobody else gives a more useful >>> response but... >>> >>> #1 - what is the format of your output? If it's low in bitcount that >>> could make the signal more dirty i believe (less resolution to make a >>> more perfect sine wave) >>> >>> #2 - have you tried calculating via doubles? >>> >>> #3 - what is data->amplitude... does that ever change or is it just a >>> one time set volume adjustment for the left and right channels? >>> >>> On Tue, Apr 26, 2011 at 12:57 PM, <eu...@lavabit.com> wrote: >>>> Hello, >>>> >>>> I want to generate two different frequency sinewaves on LineOut - >>>> Left&Right. For audio IO I'm using Portaudio(Linux, PortAudio V19-devel >>>> (built Apr 17 2011 22:00:29)), and the callback code is: >>>> >>>> static int paCallback( const void* inBuff, void* outBuff, >>>> unsigned long frpBuff, >>>> const >>>> PaStreamCallbackTimeInfo* tInf, >>>> PaStreamCallbackFlags >>>> flags, >>>> void* userData ) >>>> { >>>> int16_t i; >>>> audioData* data = (audioData*) userData; >>>> float* out = (float*) outBuff; >>>> >>>> /* Prevent warnings */ >>>> (void) tInf; >>>> (void) flags; >>>> >>>> for( i=0; i<frpBuff; i++ ) >>>> { >>>> *out++ = data->amplitude[0] * sinf( (2.0f * M_PI) * >>>> data->phase[0] ); >>>> *out++ = data->amplitude[1] * sinf( (2.0f * M_PI) * >>>> data->phase[1] ); >>>> >>>> /* Update phase, rollover at 1.0 */ >>>> data->phase[0] += (data->frequency[0] / SAMPLE_RATE); >>>> if(data->phase[0] > 1.0f) data->phase[0] -= 2.0f; >>>> data->phase[1] += (data->frequency[1] / SAMPLE_RATE); >>>> if(data->phase[1] > 1.0f) data->phase[1] -= 2.0f; >>>> } >>>> >>>> return paContinue; >>>> } >>>> >>>> When I checked the output spectrum for a 10kHz frequency using baudline >>>> (running on another PC), I got this http://images.cjb.net/80af2.png . >>>> The >>>> spectrum is clean only for output frequencies below 2-3 kHz. >>>> >>>> The tone generator inside baudline gives a clean spectrum at 10 kHz: >>>> http://images.cjb.net/b943b.png . >>>> >>>> What method would you recommend for generating a clean sinewave at 5-12 >>>> kHz? >>>> I think there is a bug somewhere, because the sine is computed in float >>>> for each sample and should be precise enough... >>>> >>>> Thanks >>>> >>>> >>>> >>>> -- >>>> dupswapdrop -- the music-dsp mailing list and website: >>>> subscription info, FAQ, source code archive, list archive, book >>>> reviews, dsp links >>>> http://music.columbia.edu/cmc/music-dsp >>>> http://music.columbia.edu/mailman/listinfo/music-dsp >>>> >>> >> -- >> dupswapdrop -- the music-dsp mailing list and website: >> subscription info, FAQ, source code archive, list archive, book reviews, >> dsp links >> http://music.columbia.edu/cmc/music-dsp >> http://music.columbia.edu/mailman/listinfo/music-dsp >> > > > > -- > dupswapdrop -- the music-dsp mailing list and website: > subscription info, FAQ, source code archive, list archive, book reviews, dsp > links > http://music.columbia.edu/cmc/music-dsp > http://music.columbia.edu/mailman/listinfo/music-dsp > -- dupswapdrop -- the music-dsp mailing list and website: subscription info, FAQ, source code archive, list archive, book reviews, dsp links http://music.columbia.edu/cmc/music-dsp http://music.columbia.edu/mailman/listinfo/music-dsp