processing / processing/p5.sound.js

p5.sound's midiToFreq() allows microtonality (decimal MIDI notes)

Open
#92 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
55
Forks
24
Avg merge
1m
Merged PRs (30d)
2

Description

### Most appropriate sub-area of p5.js?

- [ ] Accessibility
- [ ] Color
- [ ] Core/Environment/Rendering
- [ ] Data
- [ ] DOM
- [ ] Events
- [ ] Image
- [ ] IO
- [ ] Math
- [ ] Typography
- [ ] Utilities
- [ ] WebGL
- [ ] Build process
- [ ] Unit testing
- [ ] Internationalization
- [ ] Friendly errors
- [X] Other (specify if possible)

### p5.js version

1.11.1

### Web browser and version

Firefox 133.0.3

### Operating system

Windows 11

### Steps to reproduce this

### Steps:
1. Decimal numbers in midiToFreq() return microtonal values, because they're not rounded first.
2. This is actually a pretty cool feature, and allows some creative possibilites (microtonal music!), but it might be unexpected for some because [the reference](https://p5js.org/reference/p5/midiToFreq/) implies the value should be an integer MIDI note number:

> General MIDI treats notes as integers where middle C is 60, C# is 61, D is 62 etc. Useful for generating musical frequencies with oscillators.

Rather than 'fix' this, adding a note to the reference description along the lines of 'Decimal values return microtonal frequencies.' Might clarify that those values won't be rounded to equal temperament tuning, but keep a pretty cool, if unexpected, feature?

### Snippet:

```js

console.log(midiToFreq(60)); // returns 261.6255653005986 (Hz) = C4
console.log(midiToFreq(60.5)); // returns 269.2917795270241 = C4 quarter-sharp!
console.log(midiToFreq(61)); // returns 277.1826309768721 = C#4

```
I'd be happy to add this note to the reference if it's accepted.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.