[android-developers] Re: how to make sound hz?

2009-09-01 Thread guruk

thanks for all comments.
does anyone have a simple source demo.
I could try that
buffer[i] = (short) ( Math.sin((2. * Math.PI * i * f) / samplerate) *
Short.MAX_VALUE )
... and what afterwards, how to play it?

I am just wondering ( please i am a total newbie in sound)
when I fill always a buffer like above... how long is that sound??
I would be happy to create that sounds in realytime and not always had
to
create some seconds


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to make sound hz?

2009-09-01 Thread Bart van Wissen


On 1 sep, 10:01, guruk ilovesi...@gmail.com wrote:
 thanks for all comments.
 does anyone have a simple source demo.
 I could try that
 buffer[i] = (short) ( Math.sin((2. * Math.PI * i * f) / samplerate) *
 Short.MAX_VALUE )
 ... and what afterwards, how to play it?

 I am just wondering ( please i am a total newbie in sound)
 when I fill always a buffer like above... how long is that sound??

That depends on how many samples you write. The AudioTrack object
plays samples at a certain rate, for example 22050 Hz. To create a 1
second tone, you would thus have to write 22050 samples.

I am not familiar with android's AudioTrack interface, but I'm sure
the reference manual will help you there. I suppose when you call play
() it will start playing as soon as you write enough data to it with
write(). So you can generate the tone while it's playing.

It's not a completely trivial subject as you have to get into how
digital audio actually works, so if you're completely new to that you
might want to try to find some kind of library to help you out.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to make sound hz?

2009-08-31 Thread Eduardo Aquiles

You could use AudioTrack. But you will need to create the data to send
to it.


On Aug 31, 2:19 pm, guruk ilovesi...@gmail.com wrote:
 sorry i just dont find that simple thing.
 how to create a tone lets say 10khz / 5 secs

 something like that,, just play a individual created sound, not
 playing a mpg or so?

 any example will be helpful

 thx
 chri

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to make sound hz?

2009-08-31 Thread Bart van Wissen

You will have to create the wave data yourself using a sine-function.
Fill a buffer of shorts (for 16 bit audio) with something like this:

buffer[i] = (short) (Math.sin(((double) i / samplerate) * f) *
Short.MAX_VALUE);

(please correct me if I'm wrong)

If you need a 5 seconds tone, I suppose you could just fill a buffer
of size 5 * samplerate, but you could also try something smart with a
loop and repeatedly feed the same buffer to the AudioTrack object.
Just be aware of rounding errors and aliasing.



On 31 aug, 20:28, Eduardo Aquiles dudu...@gmail.com wrote:
 You could use AudioTrack. But you will need to create the data to send
 to it.

 On Aug 31, 2:19 pm, guruk ilovesi...@gmail.com wrote:

  sorry i just dont find that simple thing.
  how to create a tone lets say 10khz / 5 secs

  something like that,, just play a individual created sound, not
  playing a mpg or so?

  any example will be helpful

  thx
  chri


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to make sound hz?

2009-08-31 Thread Bart van Wissen

I'm sorry, the formula is wrong.
I think it's

buffer[i] = (short) ( Math.sin((2. * Math.PI * i * f) / samplerate) *
Short.MAX_VALUE )

But I'm not sure. I guess 3 AM is not the time to think about this.
Anyway it should give you an idea of how to do it.

On 1 sep, 02:23, Bart van Wissen bartvanwis...@gmail.com wrote:
 You will have to create the wave data yourself using a sine-function.
 Fill a buffer of shorts (for 16 bit audio) with something like this:

 buffer[i] = (short) (Math.sin(((double) i / samplerate) * f) *
 Short.MAX_VALUE);

 (please correct me if I'm wrong)

 If you need a 5 seconds tone, I suppose you could just fill a buffer
 of size 5 * samplerate, but you could also try something smart with a
 loop and repeatedly feed the same buffer to the AudioTrack object.
 Just be aware of rounding errors and aliasing.

 On 31 aug, 20:28, Eduardo Aquiles dudu...@gmail.com wrote:

  You could use AudioTrack. But you will need to create the data to send
  to it.

  On Aug 31, 2:19 pm, guruk ilovesi...@gmail.com wrote:

   sorry i just dont find that simple thing.
   how to create a tone lets say 10khz / 5 secs

   something like that,, just play a individual created sound, not
   playing a mpg or so?

   any example will be helpful

   thx
   chri


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to make sound hz?

2009-08-31 Thread Chris Stratton

On Aug 31, 8:23 pm, Bart van Wissen bartvanwis...@gmail.com wrote:

Additionally I think it's also possible to do midi through jet?

And if one isn't too particular about the sound, playing a touch tone
digit is by far the simplest

 You will have to create the wave data yourself using a sine-function.
   sorry i just dont find that simple thing.
   how to create a tone lets say 10khz / 5 secs

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---