# Sine wave "phase" in makecode

**URL:** https://forum.makecode.com/t/sine-wave-phase-in-makecode/46013
**Category:** Help
**Tags:** music, make, tool
**Created:** [September 21, 2026, 10:12pm UTC](https://forum.makecode.com/t/sine-wave-phase-in-makecode/46013 "2026-09-21T22:12:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)
#### Post date: [September 21, 2026, 10:12pm UTC](https://forum.makecode.com/t/sine-wave-phase-in-makecode/46013/1 "2026-09-21T22:12:49Z")

</div>

@richard, music.playInstructions’s Buffer is arranged something like this: (copied from Gemini)

```auto
Offset Size Type Parameter Name Value Range
----------------------------------------------------------------------
0 2 UInt16LE Sound Waveform Waveform ID
2 2 UInt16LE Frequency Start 0 to 65,535
4 2 UInt16LE Duration Milliseconds
6 2 UInt16LE Volume Start 0 to 1023
8 2 UInt16LE Volume End 0 to 1023
10 2 UInt16LE Frequency End 0 to 65,535 Hz

```

But there is no place I can enter phases, which is when the waveform starts. for example, is a sine wave had a phase of 0, the vallue at 0 would be 0. Having a phases of pi/2 would make it 1. This could be helpful for additive reconstructive synthesis, and we could in theory play any audio file in makecode. The issue is, right now playInstructions has no phase value to do it. that means the audio would be up to 50% worse! Can you add it some how, or is it supported somewhere?

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [September 21, 2026, 10:40pm UTC](https://forum.makecode.com/t/sine-wave-phase-in-makecode/46013/2 "2026-09-21T22:40:57Z")

</div>

i don’t think adding a phase to the instruction would get you significantly closer to playing audio files (i like to think that i’m pretty familiar with this particular subject).

if i were to change the play instructions buffer format it would break a _lot_ of stuff so i’d need a pretty strong reason to do so.

one thing i might consider doing is adding some more sine wave options to the waveform field, similar to what we do for duty values on square waves. but i don’t think that would give you the fidelity you’re looking for and it would only actually make a difference if you were rapidly switching phase or playing multiple notes simultaneously to get some phase cancellation effects… it would be pretty niche overall. unless you can demonstrate a compelling use case i’m not sure it would be worth doing.

---

<div class="post-metadata">

### Author: ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)
#### Post date: [September 22, 2026, 3:19am UTC](https://forum.makecode.com/t/sine-wave-phase-in-makecode/46013/3 "2026-09-22T03:19:57Z")

</div>

@richard, you could probably design a playSineBuffer, which would be mostly the same thing but only sine (but with phase). I want to try to use ARS (Additive Reconstructive Synthesis) to play a normal sound file. I think this could work, since playInstructions talks to AudioContext, which is a function made in the browser. That means that AudioContext plays at whatever sample rate the device is (e.g. 44,100 or 48000 hz), rather than at 1000 hz. playInstructions I believe can only be given a waveform to play at a 1000 hz rate. The are around 48 samples (depending on the system) between each frame. By using ARS, I could play a couple sine waves every frame, and I would 100% replicate some frames. But to accurately use ARS, I need access to phase. This is why I am asking for it.

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [September 22, 2026, 3:44am UTC](https://forum.makecode.com/t/sine-wave-phase-in-makecode/46013/4 "2026-09-22T03:44:31Z")

</div>

sorry, i just don’t think it makes sense to add.

even if i surfaced something like that, just for the browser and not for hardware, the reality of javascript running in the browser means that it wouldn’t be executing at audio rate. there is an [API](https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletNode) for generating low-level audio samples, but at that point we might as well just do the work to add sample playback.

also, makecode projects aren’t meant for storing large binary files like music or video. for one thing, there isn’t enough flash space on microcontrollers to hold that and the user’s code. and our sharing system wasn’t meant to hold large files anyhow. as soon as we added support for any sort of audio playback, i guarantee you that people would start attempting to to make projects with entire songs and run into all sorts of bugs/issues.

overall, while i appreciate that people like to experiment with audio playback, i wouldn’t expect it to be something that we support or add APIs for anytime soon (or ever)
