Help with music variables

@VoxelMaster64 the sad truth is that i have a lot of stuff to do and i can’t respond to every post! i try to spread my time among everyone and you ask a lot of questions (that’s not a complaint! just an explanation)

it’s definitely possible to change pitch and amp over time! sounds in makecode are created using buffers of sound “instructions”. each instruction has the following properties:

  • waveform
  • duration
  • start frequency
  • end frequency
  • start volume
  • end volume

you can render pitch bend events, envelopes, and more by chaining these instructions together.

if you want to see an example of this, check out the renderInstrument function:

the code here is complicated, but i added lots of comments that explain what it’s doing. this is how we render sounds for the instruments in the song editor by chaining together a ton of these sound instructions

as for how to make specific instruments, i recommend experimenting with layering different frequencies and playing with different envelopes and waveforms! also, check out the music projects by @WoofWoof and @UnsignedArduino, they’ve done lots of work recreating specific instruments

as for effects, there are some effects that you might be able to fake, like an echo or pitch shifting, but we don’t have any built in effects pipeline or anything like that.

finally: sharing. there’s no good way to export text from a makecode project, but you can work around this with three ways:

  1. QR code as you mentioned. there is a QR code extension but the amount of data you can include is pretty limited
  2. printing to console.log. this is the easiest want to do, but obviously relies on the user opening the console and copying the text
  3. finally, hosting the game in a github repo and injecting your own custom javascript into the page so that you can output the code in an easily copyable format. see @jwunderl’s recent post for more info on the types of things you can do here. this requires the most effort, but it’s what i would go for if i was doing something like this
4 Likes