Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 17 tasks
thrly opened this issue Jan 4, 2025 · 1 comment
Open
1 of 17 tasks

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

thrly opened this issue Jan 4, 2025 · 1 comment
Labels

Comments

@thrly
Copy link

thrly commented Jan 4, 2025

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
  • 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 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:

  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.

@thrly thrly added the Bug label Jan 4, 2025
Copy link

welcome bot commented Jan 4, 2025

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant