Re: [Alsa-user] pcm_min.c trouble with modification

2009-04-20 Thread Clemens Ladisch
MichaƂ Kowalczyk wrote:
   SND_PCM_FORMAT_U8, //changing this type for any other gives an error in 
 the output: segmentation fault.

U8 has one byte per sample; if you try to use a bigger sample format,
you have to enlarge the buffer accordingly.

   1, //argument responsible for channels; if I change it to 2(stereo) 
 program gives an segmentation fault error.

Using two channels would double the buffer size, too.

   48000, //sampling rate; works good but if I modify this to lower value 
 the time of generating noise will be longer, don't know why.

If the sample rate is lower, you need more timer to play the same number
of samples.

 frames = snd_pcm_writei(handle, buffer, sizeof(buffer));

The last parameter is measued in frames, not in bytes.  When you use
another sample format than U8/S8 or more then one channel, you have to
divide the buffer size by the number of bytes per frame.


HTH
Clemens

--
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] pcm_min.c trouble with modification

2009-04-17 Thread Clemens Ladisch
MK wrote:
 I want to write a simple ALSA application. I have downloaded pcm_min.c
 from ALSA documentation and try to do some modifications in code like
 change channels to stereo or sampling rate to 44100Hz. But every time
 program fails. Can anybody explain me why this is happening?

Please show your changes.


Best regards,
Clemens

--
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] pcm_min.c trouble with modification

2009-04-10 Thread Sergei Steshenko
On Thu, 9 Apr 2009 18:02:56 -0600
s. keeling keel...@nucleus.com wrote:


 You'd think grep + sed would be good for the initial change, then
 you're left with tracking down every instance where that didn't work.
 At least, that's how I write code (or maintain others' cruft).
 
 Too many cooks in the kitchen, working by their own rules?  :-P
 
 


No, I don't think grep + sed would be enough.

There are cases when literal 44100, 48000 are legitimate - when
there is a table describing card capabilities WRT sampling rate.

And, AFAIR, in dmix there is just 48000 instead of DEFAULT_SAMPLE_RATE
to be introduced.

To me it all looked really a mess, so, I think, you'll need to
go over the code in much more detail than I did, to formulate
for yourself the structure of #define statement, etc.

I was probably supposed to file a bug report regarding all this,
but somehow I'm feel hopeless and was very tired when I was doing
this auditing.

Regards,
  Sergei.

--
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Alsa-user] pcm_min.c trouble with modification

2009-04-09 Thread MK
Hello.
I want to write a simple ALSA application. I have downloaded pcm_min.c from 
ALSA documentation and try to do some modifications in code like change 
channels to stereo or sampling rate to 44100Hz. But every time program fails. 
Can anybody explain me why this is happening?

--
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] pcm_min.c trouble with modification

2009-04-09 Thread Sergei Steshenko
On Thu, 09 Apr 2009 23:32:59 +0200
MK matern...@o2.pl wrote:

 Hello.
 I want to write a simple ALSA application. I have downloaded pcm_min.c from 
 ALSA documentation and try to do some modifications in code like change 
 channels to stereo or sampling rate to 44100Hz. But every time program fails. 
 Can anybody explain me why this is happening?
 
 --
 This SF.net email is sponsored by:
 High Quality Requirements in a Collaborative Environment.
 Download a free trial of Rational Requirements Composer Now!
 http://p.sf.net/sfu/www-ibm-com
 ___
 Alsa-user mailing list
 Alsa-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/alsa-user
 

Regarding the sample rate - I once audited ALSA source to see how sample
rate is dealt with.

My naive expectation was ALSA as a whole was written with single point
of change in mind.

Alas, according to my observation, it's not the case, i.e. it is not
possible to change ALSA code in just _one_ place to change default
sample rate.

I even wrote an Email to this list with single point of change in the
subject - I know the developers monitor the list.

This Email apparently remains unanswered.

Look for single point of change in the list archive.

Regards,
  Sergei.

--
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] pcm_min.c trouble with modification

2009-04-09 Thread s. keeling
Incoming from Sergei Steshenko:
 On Thu, 09 Apr 2009 23:32:59 +0200
 MK matern...@o2.pl wrote:
  
  I want to write a simple ALSA application. I have downloaded
  pcm_min.c from ALSA documentation and try to do some modifications
  in code like change channels to stereo or sampling rate to
  44100Hz. But every time program fails. Can anybody explain me why
  this is happening?
 
 Regarding the sample rate - I once audited ALSA source to see how sample
 rate is dealt with.

Thankyou.

 My naive expectation was ALSA as a whole was written with single point
 of change in mind.
 
 Alas, according to my observation, it's not the case, i.e. it is not
 possible to change ALSA code in just _one_ place to change default
 sample rate.

Wow.  Isn't that what the #include directive is for?

You'd think grep + sed would be good for the initial change, then
you're left with tracking down every instance where that didn't work.
At least, that's how I write code (or maintain others' cruft).

Too many cooks in the kitchen, working by their own rules?  :-P


-- 
Any technology distinguishable from magic is insufficiently advanced.
(*) Please don't Cc: me.
- -

--
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user