Silence is golden
jhoyoza
Posts: 72
Hello,
Every time I start to think I’m getting smarter, “Whamo,” hit right off the forehead with another dose of reality!
I’m trying to create frequency sequences that allow me to extend the time of a specified frequency beyond the command’s limit of 65535 (about a minute). There is no real problem in doing that simply by repeating the command, and I don’t even mind if there is a silent gap between reinitializing the command. However, instead of a brief moment of silence I get a rather loud popping noise. Brief but annoying especially at higher volumes and frequencies. I tried to EQ it out, with minimal success, as it appears to be more bass orientated.
Is there something I can do to the code or is it more of an analog component issue? I’m using the line-input on my computer’s soundcard as an amplifier with a home-made cable salvaged from a broken set of headphone wires. Below, I attached the two circuits diagrams that I’ve tried. The one with the 10K resistor appears to be the quieter of the two. However, I would very much like to be able to not have any “popping” sound at all if possible? Any suggestions?
Thanks!
-J
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse]I/O Definition ]
Speaker PIN 9
'
[noparse][[/noparse] Constants ]
Amount CON 100
Time CON 65535
'
[noparse][[/noparse] Variables ]
frequency VAR Word
repeat VAR Byte
'
[noparse][[/noparse] Program Code]
frequency = 2000
DO
ON repeat GOSUB Increase_Freq
repeat = repeat + 1 // 3
IF (frequency > 3000) THEN END
DEBUG "tone sending ",DEC frequency, CR
FREQOUT Speaker ,Time, frequency
LOOP
'
[noparse][[/noparse] Subroutines]
Increase_Freq:
frequency = frequency + Amount
RETURN
Every time I start to think I’m getting smarter, “Whamo,” hit right off the forehead with another dose of reality!
I’m trying to create frequency sequences that allow me to extend the time of a specified frequency beyond the command’s limit of 65535 (about a minute). There is no real problem in doing that simply by repeating the command, and I don’t even mind if there is a silent gap between reinitializing the command. However, instead of a brief moment of silence I get a rather loud popping noise. Brief but annoying especially at higher volumes and frequencies. I tried to EQ it out, with minimal success, as it appears to be more bass orientated.
Is there something I can do to the code or is it more of an analog component issue? I’m using the line-input on my computer’s soundcard as an amplifier with a home-made cable salvaged from a broken set of headphone wires. Below, I attached the two circuits diagrams that I’ve tried. The one with the 10K resistor appears to be the quieter of the two. However, I would very much like to be able to not have any “popping” sound at all if possible? Any suggestions?
Thanks!
-J
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse]I/O Definition ]
Speaker PIN 9
'
[noparse][[/noparse] Constants ]
Amount CON 100
Time CON 65535
'
[noparse][[/noparse] Variables ]
frequency VAR Word
repeat VAR Byte
'
[noparse][[/noparse] Program Code]
frequency = 2000
DO
ON repeat GOSUB Increase_Freq
repeat = repeat + 1 // 3
IF (frequency > 3000) THEN END
DEBUG "tone sending ",DEC frequency, CR
FREQOUT Speaker ,Time, frequency
LOOP
'
[noparse][[/noparse] Subroutines]
Increase_Freq:
frequency = frequency + Amount
RETURN
bmp
585K
Comments
I think ifyou look in to the OUTPUT commands, you might find out how to designate the pin as an output.
Also, you might want to make the state of your pin low before you go in to the rest of the program.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Unfortunately, I tried your suggestion, and that didn’t seem to help.
The manual talks about the fact that if the, “10K was tied to +5V then it would put a high (1) on the pin and the output command can override this state by writing a low (0) to bit 9 of outs and changing the pin to an output.”
Anyway, I fooled around with it and didn’t have any success. Out of curiosity, I did hook it directly to an 8 ohm speaker without and amplifier and the “pop” is still there? So I think I can rule out the soundcard as being the culprit. I wonder if I can lower the amplitude a millisecond or two right before changing the frequency?
I would bet a cookie that the noise may be able to be filtered out by the correct placement of a filter capacitor of the proper value. However, It is beyond my knowledge and perhaps someone out there may know more about it.
Do you want Chocolate-Chip or Sugar?
P.S. I did figure out how to sustain a frequency indefinitely using a BS2, thus eliminating the "popping" noise while sustaining a single frequency, however I can’t quite figure out how to break out of it to change the frequency? Perhaps a programming guru might be able to advice me there?
Thanks!
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
Speaker CON 0
'
[noparse][[/noparse] Constants ]
Modulus CON $100
NoteTime CON 3
'
[noparse][[/noparse] Variables ]
tone VAR Word
'
[noparse][[/noparse] Program Code ]
tone = 2000
Main:
DO
FREQOUT Speaker, NoteTime */ Modulus, tone 'frequency plays indefinitely
LOOP
.
Hope this helped!
·
It worked! I should have known that DC will not pass through a capacitor…..I believe it is on page 2 of electronics 101.….duh. And as far as not recognizing it as such, well the proof is in the pudding as far as my experience goes…
Desy you deserve a whole box of cookies and P.J. it looks like cigars for you!
Thanks to people like yourselves, Steve and countless others in this forum it truly makes this a most enjoyable learning experience for me.
Thanks to all!
Plus, I look smart to my friends. (Drawing another bull’s eye on forehead.)
The coupling capacitor worked?! The sound is created using PWM at a relatively high frequency. The coupling capacitor acts as a high pass filter that allows the PWM frequencies through but not the very low frequency DC (vout=0) that is present between each FREQOUT. Ideally you would have a highpass filter in order to center the waveform, and then a lowpass filter to turn the PWM into a nice sine waves with limited bandwidth. Your sound card probably acts as a lowpass filter, although if it does not have antialiasing filters at its inputs, you might hear some funny squeeks and howls if the high frequency PWM mixes with the sampling frequency of the sound card.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
What you describe is correct, and the effect can even be more emphasized if you have two frequencies that create a beat frequency to one another.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Ok, admittedly improved would have been a better term than worked. There is certainly a noticeable difference and is relatively acceptable for my purposes. Obviously your capable of understanding what it sounded like without it. Now to totally get rid of it, that would be wonderful.
Your demonstration code and explanation is outstanding. However, I thought I would respond ASAP to let you know it is going to take me a little bit of time to think this one out. No doubt, the click is more pronounced when the frequency is cut off at higher amplitudes. Notice I used the term “click” not “pop” and I’m still giving out those cookies.
Now lets see who gets the box of chocolates!
My first thought is how can I adjust the timing to land perfectly with the end of the sign wave. There should be no audible difference as it should be something less than one cycle. That is if my thinking is in line with what your describing. Actually doing it is another story.
Second, as I mentioned earlier, I may be able to fade out the amplitude just before changing frequencies or repeating the command, thus creating a situation where there is nothing to hear momentarily. I did mention I can live with a bit of silence.
Third is building a low-band pass filter as you suggested. I do have a few examples that use a 741 op-amp however I have a feeling that digital processing may be a different animal all together. It is obvious I have minimal knowledge of either and perhaps I may want to darken up the bulls-eye, on my forehead, a bit before I say anymore.
When researching the term anti-aliasing I find the math involved is certainly going to require cleaning out a few of the old spider-webs and most likely beyond my capabilities. I do find it ironic that distortion, if properly applied, actually adds clarity. I’m intrigued at the prospect of reading more about it and how it may be apply to digital signal processing. Who knows maybe I will get lucky?
Like I said, I have a lot to think about and do not know if any of it is even possible taking into consideration my limited knowledge. In the mean time, I’m going to go find a permanent marker and I welcome input from anyone and everyone in regards to this discussion!
If nothing else, I certainly enjoy learning more about all of these things.
Respectfully yours,
-J
You know you can get some quite nice "bell" sounds from the Stamp FREQOUT command, by using two frequncies and a time interval that brackets even multiples of 1/2 cycle of the beat note frequency that Beau mentioned.
In old phonographs or amateur radio we used to use a "pop filter" or "blanking filter". This would detect a pulse above threshold at an early stage in the amplifier chain, and for the duration of that pop in effect turn off the amplifier or hold the output at a pre-pop level. That sort of filtering is easy to accomplish with a digital filter, but more difficult with analog, because of the predictiveness of knowing when the pop has already occured, and then going back in time to filter it out. Time delays, digital or analog. I'm not sure exactly how to go about it with the PWM signal.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com