[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Calculating Semitones in an octave

**From**: |
Andrew Janke |

**Subject**: |
Re: Calculating Semitones in an octave |

**Date**: |
Wed, 29 Jan 2020 12:00:37 -0500 |

**User-agent**: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 |

On 1/29/20 11:53 AM, harish3679 wrote:
>* Hi guys,*
>* *
>* To find frequency using semitones value from A=440Hz*
>* *
>* We have, f = 2^(n/12)*440 //where n is the semitone value*
>* *
>* Now, to find semitone value for A=432Hz from 440Hz*
>* *
>* It is 432 = 2^(n/12)*440*
>* *
>* I came up with 2^n=0.92668*
>* *
>* Although have no clue how to calculate this in octave rather got an error*
>* saying*
>* *
>* "2^(n)=0.92668*
>* parse error:*
>* *
>* invalid left hand side of assignment"*
>* *
>* Someone, please shed light on this part*
>* *
>* *
>* Regards,*
>* Harish*
>* *
You can't write arbitrary equations in Octave and have them figure it
out. The "=" sign is an assignment operation, and you need to have a
single variable on the left hand side. So re-work your equation so that
n is by itself on the left hand side.
I think this means taking the base-2 logarithm of both sides, and ending
up with:
n = log2(0.92688)
And that you can run in Octave:
>*> log2(0.92668)*
ans = -1.098568597196845e-01
Cheers,
Andrew