Intricacies of volume

I’ve been playing with volume in MakeCode Arcade and had a few questions.

1.There’s a set volume block but there doesn’t appear to be a way to read this value, is that correct? Any plans to change this?
2. The default value in the set volume block is 20 but this seems far quieter than the default if the volume has not been set. What is the default volume?
3. The volume in the window that pops up when you press select on the PyGamer appears to be the same value as the one set in code, is that the case?
4. Has there been consideration of a mute feature for the devices? One that preserved the previous volume when unmuted. The simulator has this but it’s not on the runtime for the devices.
5. The simulator’s default (fixed?) volume seems really loud by default. This always surprises me on late night coding sessions. I think this is also the cause of the volume difference in this John Park recording/video (YouTube).
6. Is the game over tune at the same volume as the notes played by the application? Another example from John Park’s video (YouTube).
7. The actual perceived default volume of notes seems to have changed a fair but over different versions of MakeCode (e.g. Adafruit Forums: MakeCode Tutorials and Sound Broken). Is this now stable?

1 Like

Lots of good questions, and I don’t know that I have full answers to all of them at this time but here’s my first answer (we can amend it as we get it more solid):

  1. I don’t see a reason to not have a block for that personally, beyond there just being a ton of blocks in arcade - will need to discuss this one separately, an issue on github for this would be great if you have time so we can discuss it there (there is a javascript function to do this for now, which will just convert to a gray block: music.volume())
  2. In the browser the default is 128, but I believe the default volume is defined by the bootloader, so different board manufacturers can define them independently… Need to double check this. Either way, I think the value in set volume should probably default to the sim default and not 20.
  3. Yes, the menu screen just uses and sets the volume using the same apis as the blocks
  4. I would like that personally, and I’m pretty sure it’s been discussed, but it is currently blocked on persistent storage like persistent high scores is.
  5. Good feedback, I think it’s fair to say we should adjust this a bit.
  6. Game over currently uses a different waveform from the standard nodes, which does make feel louder than it would normally (can see it here: the ~15 makes it a square wave which can be perceived as higher volume, in particular for these tones)
  7. I think we probably need to play with it a bit more (in particular in arcade) to make the volume feel more consistent / less blaringly loud depending on the blocks used, so unfortunately I don’t think we can necessarily say it’s stable quite yet. (I have the pygamer with the speaker from adabox 12 and sometimes I forget exactly how loud it is and until I load a game and lose…) Any feedback / particular cases where you’re surprised by the volume (too quiet / to loud / doesn’t feel right in general) would be great to have as data points to use for adjusting it, though.
1 Like

Thanks for the extensive answer. I think I’d like to be able to have quiet and loud sound effects in the game and that implies control over volume beyond just a global volume control but I’m still pondering this.

A physical dial for global volume would be my preference but the devices aren’t built that way :frowning:

The play functions on Melody class have a volume parameter.

There appears to be a lot you can do with JavaScript based on MakeCode Arcade Developer: Music and Sounds but I’m trying to stick to blocks to keep code accessible to a wide audience. I appreciate there’s a balance here between functionality vs wading through thousands of blocks. That plus sign feature of the blocks is an interesting way of hiding functionality that only some users want to use.

BTW, for that representation of music notes, how are sharps/flats (black notes on a piano) specified?

Extensions look like an obvious way to offer more advanced blocks for use in specific projects where they are needed. I’ll try and find some time to look into that for more advanced audio.