in [Python]

Prev: dict's as dict's key.
Next: enhancing 'list'
From: Alf P. Steinbach on 14 Jan 2010 11:56 * Grant Edwards: > On 2010-01-14, Alf P. Steinbach <alfps (a)start.no> wrote:> >>> It's not clear to me that you can approximate any waveform >>> with a suitable combination of square waves, >> Oh. It's simple to prove. At least conceptually! :-) > > [...] > >> With the goal of just a rough approximation you can go about >> it like this: >> >> 1. Divide a full cycle of the sine wave into n intervals. >> With sine wave frequency f this corresponds to n*f >> sample rate for digital representation. >> >> 2. Each interval will be approximated by a rectangular bar >> extending up to or down to the sine wave. As it happens >> this (the bar's height) is the sample value in a digital >> representation. >> >> 3. In the first half of the cycle, for each bar create that >> bar as a square wave of frequency f, amplitude half the >> bar's height, and phase starting at the bar's left, plus >> same square wave with negative sign (inverted amplitude) >> and phase starting at the bar's right. And voil?, not >> only this bar generated but also the corresponding >> other-way bar in second half of cycle. >> >> 4. Sum all the square waves from step 3. >> >> 5. Let n go to infinity for utter perfectness! :-) >> >> And likewise for any other waveform. >> >> After all, it's the basis of digital representation of sound! > > Huh? I've only studied basic DSP, but I've never heard/seen > that as the basis of digital represention of sound. Oh, you have... The end result above (for finite n) is a sequence of sample values of a sine wave. Ordinary digital representation of sound is exactly the same, a sequence of sample values. > I've also never seen that representation used anywhere. Yes, you have. A sequence of sample values is the representation used in any direct wave file. Like [.wav] and, I believe, [.aiff]. > Can you provide any references? I don't have any references for the above procedure, it's sort of trivial. Probably could find some references with an hour of googling. But no point. Cheers & hth., - Alf PS: To extend the above to a non-symmetric waveform, just first decompose that waveform into sine waves (Fourier transform), then add up the square wave representations of each sine wave. :-)
From: Steve Holden on 14 Jan 2010 12:04 Grant Edwards wrote: > On 2010-01-14, Alf P. Steinbach <alfps (a)start.no> wrote:[bogus hand-waving] >> After all, it's the basis of digital representation of sound! > > Huh? I've only studied basic DSP, but I've never heard/seen > that as the basis of digital represention of sound. I've also > never seen that representation used anywhere. Can you provide > any references? > Of course he can't. And it isn't the basis of analog quantization. And I suspect Alf has never hear of Shannon's theorem. But don't listen to me, apparently I'm full of it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS: http://holdenweb.eventbrite.com/
From: Alf P. Steinbach on 14 Jan 2010 12:18 * Steve Holden: > Grant Edwards wrote: >> On 2010-01-14, Alf P. Steinbach <alfps (a)start.no> wrote:> [bogus hand-waving] >>> After all, it's the basis of digital representation of sound! >> Huh? I've only studied basic DSP, but I've never heard/seen >> that as the basis of digital represention of sound. I've also >> never seen that representation used anywhere. Just for the record: Grant has seen that representation numerous times, he just didn't recognize it. > Can you provide any references? >> > Of course he can't. And it isn't the basis of analog quantization. Of course it isn't the basis of quantization: it *is* quantization, directly. Which is the basis of digital representation. > And I suspect Alf has never hear of Shannon's theorem. It's about 30 years since I did that stuff. > But don't listen to me, apparently I'm full of it. You're spouting innuendo and personal attacks, repeatedly, so that seems to be the case, yes. :-) Cheers, - Alf
From: Steve Holden on 14 Jan 2010 13:16 Alf P. Steinbach wrote: > * Steve Holden: >> Grant Edwards wrote: >>> On 2010-01-14, Alf P. Steinbach <alfps (a)start.no> wrote:>> [bogus hand-waving] >>>> After all, it's the basis of digital representation of sound! >>> Huh? I've only studied basic DSP, but I've never heard/seen >>> that as the basis of digital represention of sound. I've also >>> never seen that representation used anywhere. > > Just for the record: Grant has seen that representation numerous times, > he just didn't recognize it. > > >> Can you provide any references? >>> >> Of course he can't. And it isn't the basis of analog quantization. > > Of course it isn't the basis of quantization: it *is* quantization, > directly. > Nope, quantization is taking the *instantaneous value* of a waveform and using that as the representation for one sample period. That is nowhere near the same as summing periodic square waves. > Which is the basis of digital representation. > Well at least we agree that quantization is the basis of digital representations. But I've never seen any summed square wave presentation of it. > >> And I suspect Alf has never hear of Shannon's theorem. > > It's about 30 years since I did that stuff. > Well me too, but information theory is, after all, the theoretical underpinning for the way I make my living, so I felt obliged to study it fairly thoroughly. > >> But don't listen to me, apparently I'm full of it. > > You're spouting innuendo and personal attacks, repeatedly, so that seems > to be the case, yes. :-) > Nothing personal about it. I'm just asking you to corroborate statements you have made which, in my ignorance, I consider to be bogus hand-waving. Nothing about you there. Just the information you are promoting. I don't normally deal in innuendo and personal attacks. Though I do occasionally get irritated by what I perceive to be hogwash. People who know me will tell you, if I am wrong I will happily admit it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS: http://holdenweb.eventbrite.com/
From: Alf P. Steinbach on 14 Jan 2010 13:42
* Steve Holden: > Alf P. Steinbach wrote: >> * Steve Holden: >>> Grant Edwards wrote: >>>> On 2010-01-14, Alf P. Steinbach <alfps (a)start.no> wrote:>>> [bogus hand-waving] >>>>> After all, it's the basis of digital representation of sound! >>>> Huh? I've only studied basic DSP, but I've never heard/seen >>>> that as the basis of digital represention of sound. I've also >>>> never seen that representation used anywhere. >> Just for the record: Grant has seen that representation numerous times, >> he just didn't recognize it. >> >> >>> Can you provide any references? >>> Of course he can't. And it isn't the basis of analog quantization. >> Of course it isn't the basis of quantization: it *is* quantization, >> directly. >> > Nope, quantization is taking the *instantaneous value* of a waveform and > using that as the representation for one sample period. That is nowhere > near the same as summing periodic square waves. There are two three things wrong with that paragraph. First, quantization can not physically be instantaneous. So it's pretty much moot to try to restrict it to that. Second, for the mathematical exercise you can let the measurement be an instantaneous value, that is, the value at a single point. Third, the result of quantization is a sequence of values, each value present for an interval of time, and the same is obtained by summing square waves. I'm beginning to believe that you maybe didn't grok that simple procedure. It's very very very trivial, so maybe you were looking for something more intricate -- they used to say, in the old days, "hold on, this proof goes by so fast you may not notice it!" >> Which is the basis of digital representation. >> > Well at least we agree that quantization is the basis of digital > representations. But I've never seen any summed square wave presentation > of it. Well, I'm glad to be able to teach something. Here's the MAIN IDEA in the earlier procedure: a square wave plus same wave offset (phase) and negated, produces a set of more rectangular waveforms, which I called "bars" -- in between the bars the two square waves cancel each other: _ | | | | ______| |______ ______ | | | | |_| The bars alternate in positive and negative direction. They can be made as narrow as you wish, and when they are as narrow as each sample interval then each bar can represent the sample value residing in that interval. Even a sample corresponding to a point measurement (if such were physically possible). And samples are all that's required for representing the sine. And happily the alternation of upgoing and downgoing bars is matched by an identical alternation of the sine wave. :-) Otherwise it would be a tad difficult to do this. But then, representing sines is all that's required for representing any wave form, since any wave form can be decomposed into sines. >>> And I suspect Alf has never hear of Shannon's theorem. >> It's about 30 years since I did that stuff. >> > Well me too, but information theory is, after all, the theoretical > underpinning for the way I make my living, so I felt obliged to study it > fairly thoroughly. >>> But don't listen to me, apparently I'm full of it. >> You're spouting innuendo and personal attacks, repeatedly, so that seems >> to be the case, yes. :-) >> > Nothing personal about it. I'm just asking you to corroborate statements > you have made which, in my ignorance, I consider to be bogus hand-waving. OK. May I then suggest going through the procedure I presented and *draw* the square waves. I dunno, but maybe that can help. > Nothing about you there. Just the information you are promoting. I don't > normally deal in innuendo and personal attacks. Though I do occasionally > get irritated by what I perceive to be hogwash. People who know me will > tell you, if I am wrong I will happily admit it. There's a difference between an algorithm that you can implement, and hogwash. Cheers, - Alf |