Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2764

Re: How to generate sound of given frequency?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <nospam@knutejohnson.com>
Newsgroups comp.lang.java.help
Subject Re: How to generate sound of given frequency?
Date Tue, 03 Sep 2013 21:38:01 -0700
Organization A noiseless patient Spider
Lines 30
Message-ID <l06dfb$l9o$1@dont-email.me> (permalink)
References <gpe8i6$h7h$1@news.onet.pl> <49baa85b$0$25637$b9f67a60@news.newsdemon.com> <57d86ca7-9948-4058-a899-d4c8a2d0c040@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 4 Sep 2013 04:38:03 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="21816"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tHJIuNlSG6uzaaUv5dkra"
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
In-Reply-To <57d86ca7-9948-4058-a899-d4c8a2d0c040@googlegroups.com>
Cancel-Lock sha1:bn4RU8rR8htrZkzXGKl2lgk7KMg=
Xref csiph.com comp.lang.java.help:2764

Show key headers only | View raw


On 9/3/2013 1:12 PM, ryanbrummet09@augustana.edu wrote:
> Hello,
>
> A little after the fact, but thank you!  I'm wondering why you scaled
> sin(angular frequency) by vol and 127.  I'm assuming this is because
> 127 corresponds to the maximum volume setting and vol is the desired
> amplitude.  Also, why did you reshape the first and last 10ms of the
> wave?
>
> Again thank you very much. I've spent some time trying to figure this
> out and your code was the first that I came across that was straight
> forward.
>
> Sincerely, Ryan
>

The audio format uses signed data one byte in length.  A byte can hold 
values from -128 to 127.  The data is basically amplitude modulation, so 
that a signal from -127 to 127 would be the loudest volume possible. 
The shorter the period of time it takes to make the transition would 
increase the frequency of the tone.

The shaping is to prevent clicks in the sound at the beginning and end 
of the tone.  I should really change the ramp to something more 
logarithmic rather than sawtooth.  The effect I was trying to achieve is 
similar to what is done with continuous wave radio transmission.

-- 

Knute Johnson

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: How to generate sound of given frequency? ryanbrummet09@augustana.edu - 2013-09-03 13:12 -0700
  Re: How to generate sound of given frequency? "John B. Matthews" <nospam@nospam.invalid> - 2013-09-03 22:01 -0400
  Re: How to generate sound of given frequency? Knute Johnson <nospam@knutejohnson.com> - 2013-09-03 21:38 -0700
  Re: How to generate sound of given frequency? Roedy Green <see_website@mindprod.com.invalid> - 2013-09-09 01:46 -0700
    Re: How to generate sound of given frequency? Knute Johnson <nospam@knutejohnson.com> - 2013-09-09 06:59 -0700
      Re: How to generate sound of given frequency? "John B. Matthews" <nospam@nospam.invalid> - 2013-09-09 15:45 -0400
  Re: How to generate sound of given frequency? Roedy Green <see_website@mindprod.com.invalid> - 2013-10-21 20:36 -0700

csiph-web