This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import log2 | |
| just_intonation_ratios = { | |
| # Suddha swara | |
| "\n## Suddha swara": {}, | |
| "Sa" : {1.0}, | |
| "Re": {9/8, 10/9}, # Two fifths = 9/8 | |
| "Ga": {5/4}, | |
| "Ma": {4/3}, | |
| "Pa": {3/2}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Brian Kernighan's Algorithm to count set bits | |
| // Takes only as many iterations as the number of set bits | |
| fn popcount(mut num: i32) -> u32 { | |
| let mut n = 0; | |
| while (num != 0) { | |
| n += 1; | |
| num = num & (num - 1); | |
| } | |