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


Groups > comp.lang.basic.visual.misc > #658

Re: The Beep Function.

From "blank" <blank@blankety.blank.com>
Newsgroups comp.lang.basic.visual.misc
References (7 earlier) <jek9e6$85e$1@dont-email.me> <ff462f86-bd0b-42bf-b52d-16eb4e1c792e@t8g2000yqg.googlegroups.com> <jep386$7m8$1@dont-email.me> <b064af06-d5b9-4181-8d1a-d5e2d3e0b073@r5g2000yqc.googlegroups.com> <jeqbgd$kmt$1@dont-email.me>
Subject Re: The Beep Function.
Date 2012-01-14 19:50 +1100
Message-ID <4f1141d3$1@dnews.tpgi.com.au> (permalink)

Show all headers | View raw


"Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message 
news:jeqbgd$kmt$1@dont-email.me...
> "Peter Nolan" <peter.nolan40@gmail.com> wrote in message 
> news:b064af06-d5b9-4181-8d1a-d5e2d3e0b073@r5g2000yqc.googlegroups.com...
> On Jan 13, 11:06 am, "DaveO" <d...@dial.pipex.com> wrote:
>>> So what's the problem? Ramping a variable for the first and
>>> last n steps of a loop is pretty trivial however I've no idea if
>>> it will actually work to fade in and out the WAV, the easiest
>>> way to find out would be to try it out.
>>
>> Hello DaveO. Softening up the WAV file using ramps at the
>> start and finish of the file will definitely work because I have
>> checked all this out using Audacity. It's just a matter of getting
>> the code to build in the two ramp functions to work and then
>> playing round with the slope of that function to eliminate the pops.
>
> I hope you don't take this the wrong way Peter but I'm having a little 
> trouble reconciling your desire to "know what goes on under the hood" with 
> your reluctance to have a go at modifying the existing wav file code in 
> order to produce the fade in and the fade out sections.
>
> Don't worry about writing code that fails to work first time, or even that 
> fails to work at all. We all do that sometimes. In fact we all do it a 
> lot, if we are honest with ourselves. That's how we learn. If it fails to 
> work first time then try again. If after trying for some time you find 
> that you just cannot get it at all then you haven't lost anything, except 
> perhaps a bit of time, and you might actually have learned quite a lot. 
> Also, the people here will be far more inclined to help you with the 
> details of your code if you have tried and failed than they will if you 
> have never tried at all. As a starter, have a look at the declaration of 
> the main array in the example code, which is as follows:
>
> ReDim wavfile(1 To totalsamples + 22)
>
> That array is an array of VB Integers. The first 22 elements of it contain 
> the "description of the wav file" and the remaining elements contain the 
> actual sample voltage data. So, for simplicity you could start off by 
> declaring two new variables that contain the start point and the end point 
> of the actual wave data samples in the wavfile array, perhaps something 
> like:
>
> Dim FirstSample as Long, LastSample as Long
> FirstSample = 23
> LastSample = totalSamples + 22
>
> Next you need to decide how many samples you want to modify at each end in 
> order to create the fade-in and the fade-out so as to reduce or eliminate 
> the "blip noise". My own suggestion is to start off using about one 
> hundredth of a second at each end of the total waveform. If this doesn't 
> reduce the "pop" sufficiently then use a larger value, perhaps two, three 
> or four hundredths of a second (although I think the first one will work 
> for you). This particular code always generates a wav file at the sample 
> rate of 44100 samples per second (what used to be known as the standard 
> "CD music" rate). So, if there are always 44100 samples in one second then 
> there will always be 441 samples in one hundredth of a second, regardless 
> of the sine wave frequency of the tone the code is generating. So that 
> gets you another variable you can declare and populate:
>
> SlopeSamples = 441
>
> I would suggest that for simplicity you tackle the "fade-in" section 
> first. Also, both for simplicity and for speed, I would suggest that you 
> add your own "fade-in" code AFTER the main waveform has been fully 
> created, in other words AFTER the following section in the existing code:
>
> For n = 0 To totalsamples - 1
> d1 = Amplitude * Sin(k)
>    wavfile(n + 23) = d1
>    k = k + dAngle
> Next n
>
> So, immediately after the code shown above you will need to add your own 
> variable declarations and populate them with the correct values (as 
> already explained above) and you will need to add your own For . . . Next 
> loop for the "Fade In" code which (for this simple linear fade) reads one 
> by one the first 441 actual data samples and modifies each of them by 
> multiplying it by some value in the range zero to 1 and and dumps it back. 
> For the "fade-in" the 441 samples should in turn be multiplied by a 
> floating point value which gradually increases from zero to one over the 
> complete 441 samples.
>
> When you think you have got it right then run the program and see what 
> happens. Make sure that you uncomment the lines near the end of the code 
> so that an actual .wav file is saved to disk. If your code runs without 
> error you can then load that .wav file into Audacity and see what it looks 
> like. You should be able to see the short one hundredth of a second "ramp 
> up from zero" of the waveform.
>
> Give it a go, Peter. You'll learn much more by trying than you will by 
> reading code that has been posted. In fact you will probably learn much 
> more by trying and failing than you will be trying and succeeding. Believe 
> me.
>
> Mike
>
...and Peter. Here it a small tip that might save you a lot of puzzling! 
When you see a variable (that you create yourself) like CricketForIndia, you 
might be puzzled by the use of capitals. That is simply a convention to help 
break up compound words. It is not essential .  The variable could have no 
capitals. It would just be harder to read.

Back to comp.lang.basic.visual.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-04 06:15 -0800
  Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-04 07:11 -0800
  Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-04 15:38 +0000
  Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-04 16:16 +0000
    Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-04 10:15 -0800
      Re: The Beep Function. Jim Mack <no-uce-ube@mdxi.com> - 2012-01-04 13:46 -0500
        Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-05 08:09 -0800
      Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-04 22:24 +0000
      Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-05 08:22 +0000
      Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-05 09:21 +0000
        Re: The Beep Function. Gordon Levi <gordon@address.invalid> - 2012-01-05 21:54 +1100
          Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-05 11:33 +0000
            Re: The Beep Function. Gordon Levi <gordon@address.invalid> - 2012-01-06 00:20 +1100
              Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-05 17:46 +0000
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-06 14:03 +1100
                Re: The Beep Function. Gordon Levi <gordon@address.invalid> - 2012-01-08 00:43 +1100
                Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-07 20:53 +0000
                Re: The Beep Function. Gordon Levi <gordon@address.invalid> - 2012-01-08 17:27 +1100
                Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-08 09:49 +0000
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-08 08:00 +1100
                Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-07 22:43 +0000
      Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-05 14:13 +0000
        Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-05 08:26 -0800
        Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-05 08:04 -0800
        Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-07 04:41 -0800
          Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-08 11:19 +0000
        Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-10 04:52 -0800
          Re: The Beep Function. "Thorsten Albers" <gudea@gmx.de> - 2012-01-10 13:01 +0000
          Re: The Beep Function. Jim Mack <no-uce-ube@mdxi.com> - 2012-01-10 11:44 -0500
            Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-11 05:58 -0800
          Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-10 17:19 +0000
            Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-11 05:54 -0800
              Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-11 15:21 +0000
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-12 08:04 -0800
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-13 12:40 +1100
                Re: The Beep Function. ralph <nt_consulting64@yahoo.net> - 2012-01-12 21:28 -0600
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-13 15:34 +1100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-13 05:25 -0800
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-14 07:32 +1100
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-13 11:06 +0000
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-13 05:48 -0800
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-13 15:09 +0000
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-14 04:29 -0800
                Re: The Beep Function. Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2012-01-14 14:56 +0100
                Re: The Beep Function. ralph <nt_consulting64@yahoo.net> - 2012-01-14 10:24 -0600
                Re: The Beep Function. Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2012-01-14 18:51 +0100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-15 03:39 -0800
                Re: The Beep Function. Schmidt <sss@online.de> - 2012-01-15 17:39 +0100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-16 05:21 -0800
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-16 14:39 +0000
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-17 04:13 -0800
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-17 14:17 +0000
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-17 07:22 -0800
                Re: The Beep Function. "Henning" <computer_hero@coldmail.com> - 2012-01-17 17:47 +0100
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-17 16:50 +0000
                Re: The Beep Function. "Henning" <computer_hero@coldmail.com> - 2012-01-17 18:22 +0100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-18 05:26 -0800
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-18 14:35 +0000
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-18 07:10 -0800
                Re: The Beep Function. ralph <nt_consulting64@yahoo.net> - 2012-01-18 10:38 -0600
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-19 05:42 +1100
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-19 11:33 +0000
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-21 03:16 -0800
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-19 05:17 -0800
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-20 05:17 +1100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-20 03:54 -0800
                Re: The Beep Function. Jason Keats <jkeats@melbpcDeleteThis.org.au> - 2012-01-20 23:40 +1100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-21 03:20 -0800
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-21 15:20 +1100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-21 03:23 -0800
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-20 05:11 +1100
                Re: The Beep Function. Schmidt <sss@online.de> - 2012-01-17 18:58 +0100
                Re: The Beep Function. Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2012-01-17 23:13 +0100
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-18 09:12 +0000
                Re: The Beep Function. "DaveO" <djo@dial.pipex.com> - 2012-01-18 09:22 +0000
                Re: The Beep Function. ralph <nt_consulting64@yahoo.net> - 2012-01-18 05:39 -0600
                Re: The Beep Function. Helmut_Meukel <Helmut_Meukel@bn-hof.invalid> - 2012-01-18 13:32 +0100
                Re: The Beep Function. ralph <nt_consulting64@yahoo.net> - 2012-01-15 13:30 -0600
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-16 06:59 +1100
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-16 06:55 +1100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-16 06:06 -0800
                Re: The Beep Function. "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-01-13 22:34 +0000
                Re: The Beep Function. "blank" <blank@blankety.blank.com> - 2012-01-14 19:50 +1100
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-14 05:10 -0800
                Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-14 06:16 -0800
  Re: The Beep Function. "Henning" <computer_hero@coldmail.com> - 2012-01-19 20:25 +0100
    Re: The Beep Function. Peter Nolan <peter.nolan40@gmail.com> - 2012-01-20 03:56 -0800

csiph-web