Csound Csound-dev Csound-tekno Search About

[Csnd] rfft > rect2pol/mags - maximum amplitude?

Date2024-07-07 20:26
FromPierre Clisson
Subject[Csnd] rfft > rect2pol/mags - maximum amplitude?
Attachmentssmime.p7s  
Hi,

What is the maximum magnitude that can be returned by rect2pol or mags 
after rfft, assuming a rectangular window?

I am performing the analysis on a ftable converted to array. I was 
expecting the maximum amplitude to be N/2 (that is the case for a sine 
wave), but some waveforms (such as a naive square) return values up to 
2607 for an array of 4096 points.

Thanks,

Pierre


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2024-07-07 21:34
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] rfft > rect2pol/mags - maximum amplitude?
The normalisation factor is N/2. I guess if you are analysing things like a naive (non-bandlimited) square wave
you might get some mag results going over 1.0. 

Note that this is what you’d also get if you used Python & numpy

>>> import numpy as np
>>> a = np.zeros(4096)
>>> a[0:2048] = 1
>>> a[2048:4096] = -1
>>> s = np.fft.rfft(a)
>>> abs(s[1])
2607.5948432810956

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 7 Jul 2024, at 20:26, Pierre Clisson  wrote:
> 
> Hi,
> 
> What is the maximum magnitude that can be returned by rect2pol or mags after rfft, assuming a rectangular window?
> 
> I am performing the analysis on a ftable converted to array. I was expecting the maximum amplitude to be N/2 (that is the case for a sine wave), but some waveforms (such as a naive square) return values up to 2607 for an array of 4096 points.
> 
> Thanks,
> 
> Pierre
> 
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>       https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2024-07-07 22:53
FromPierre Clisson
SubjectRe: [Csnd] [EXTERNAL] [Csnd] rfft > rect2pol/mags - maximum amplitude?
Attachmentssmime.p7s  
Makes sense. Thanks!

Victor Lazzarini wrote on 07/07/2024 22:34:
> The normalisation factor is N/2. I guess if you are analysing things like a naive (non-bandlimited) square wave
> you might get some mag results going over 1.0.
>
> Note that this is what you’d also get if you used Python & numpy
>
>>>> import numpy as np
>>>> a = np.zeros(4096)
>>>> a[0:2048] = 1
>>>> a[2048:4096] = -1
>>>> s = np.fft.rfft(a)
>>>> abs(s[1])
> 2607.5948432810956
>
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 7 Jul 2024, at 20:26, Pierre Clisson  wrote:
>>
>> Hi,
>>
>> What is the maximum magnitude that can be returned by rect2pol or mags after rfft, assuming a rectangular window?
>>
>> I am performing the analysis on a ftable converted to array. I was expecting the maximum amplitude to be N/2 (that is the case for a sine wave), but some waveforms (such as a naive square) return values up to 2607 for an array of 4096 points.
>>
>> Thanks,
>>
>> Pierre
>>
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>        https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>          https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here



Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here