# Questions about MakeCode C++ sound

**URL:** <https://forum.makecode.com/t/questions-about-makecode-c-sound/42721>\
**Category:** Help\
**Created:** [March 11, 2026, 4:13pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721 "2026-03-11T16:13:27Z")\
**Posts on this page:** 20\
**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:** [March 11, 2026, 4:13pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/1 "2026-03-11T16:13:27Z")

</div>

is there a way to use the C++ layer of makecode or whatever its called? i feel like some extensions have cpp files in them, though i dont remember any. Im tryin to play partials, a type of sound, but playInstructions() or something else is making some of it sound like junk (likely makecode struggling to play hundreds at once).

---

<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:** [March 12, 2026, 6:04pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/2 "2026-03-12T18:04:08Z")

</div>

> [@VoxelMaster64](#):
>
> is there a way to use the C++ layer of makecode or whatever its called? i feel like some extensions have cpp files in them, though i dont remember any. Im tryin to play partials, a type of sound, but playInstructions() or something else is making some of it sound like junk (likely makecode struggling to play hundreds at once).

@Richard

---

<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:** [March 13, 2026, 9:27pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/3 "2026-03-13T21:27:13Z")

</div>

did a bit of researching, @richard is it true that c++ only compiles for the hardware and not the website? can this be changed, assuming it’s possible? There is also an app for makecode I believe, does that support c++ on computers? if I remember right (probably don’t), makecode can also use visual studio code (I have visual studio, would that work), does that work?

---

<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:** [March 13, 2026, 10:01pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/4 "2026-03-13T22:01:14Z")

</div>

c++ is never compiled to run in the simulator, regardless of platform. all versions of makecode (browser, vs code, offline app) work exactly the same in this regard.

your project can contain c++, it just won’t work in the simulator.

the way we “simulate” c++ code in the browser is by having completely separate browser implementations. in most of our built-in extensions, this code can be found inside a `/sim/` directory, for example here is where all the code for dealing with images/drawing in arcade lives: [https://github.com/microsoft/pxt-common-packages/tree/master/libs/screen/sim](https://github.com/microsoft/pxt-common-packages/tree/master/libs/screen/sim)

these browser implementations don’t go through the makecode compiler. as a result, they also have full access to the browser APIs. if we let extensions or projects run code that had access to browser APIs, it would be possible to, say, make a share link where it runs some simulator code that hacks your computer or starts mining bitcoin or something. for that reason, **no extension or project is allowed to contribute code that runs in the simulator**. it’s purely a security concern.

i always recommend that you try to keep all code in TS if possible

---

<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:** [March 13, 2026, 10:13pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/5 "2026-03-13T22:13:25Z")

</div>

i guess i should also mention that we do accept pull requests! if you want to add new native c++ code along with browser implementations, we would be delighted!

for example, here are some example prs from our very own forum user @kwx adding new sound waveforms

> <https://github.com/microsoft/pxt-common-packages/pull/1177>
>
> This adds a few new waveforms for special effects:
> 
> SW\_TUNEDNOISE (waveform 4)… - a variable-pitch noise based on pseudorandom impulses.
> It sounds similar to SW\_NOISE at maximum frequency, but reacts to
> the frequency parameter to modify the perceived pitch. (It reuses the
> waveform number for the retired SW\_METALLIC waveform.)
> 
> SW\_CYCLENOISE\_4, SW\_CYCLENOISE\_5, SW\_CYCLENOISE\_6 (waveforms 16-18) -
> variable-pitch short-sequence repeating pseudorandom impulses with
> 4/5/6 bit sequences (16/32/64 cycles).
> 
> The sounds are vaguely inspired by the POKEY chip used in 8-bit Atari
> computers, cf. https://www.atariarchives.org/dere/chapt07.php, with its
> 4/5/17-bit polynomial counters that modulate square waves, but uses a
> simpler generator and doesn't try to emulate any particular hardware.
> 
> See
> https://forum.makecode.com/t/testing-modifications-to-the-sound-engine/3351
> for context and links to example sound output.

> <https://github.com/microsoft/pxt/pull/7475>
>
> This adds simulator support for the new waveforms added in
> https://github.com/m…icrosoft/pxt-common-packages/pull/1177
> 
> See
> https://forum.makecode.com/t/testing-modifications-to-the-sound-engine/3351
> for context and example sound output.

---

<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:** [March 16, 2026, 5:58pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/6 "2026-03-16T17:58:24Z")

</div>

Is there a way to upload files to makecode? I have an SDIF file that is 247KB, my output file is 145KB. I could probably compress the output file into a binary file (using every UTF-8 character (0x00 - 0xFF)) and parse it with makecode, but from what I’m aware, makecode can’t do anything like that. the output file is a number[] that can be copy pasted into makecode, utf-8 encoding cannot. the utf-8 encoded file would also be around 72KB which is a huge difference, so I would appreciate it if it was added! Also, when i was trying to comporess a huge number array (base 10) into my own character set (base 85), makecode crashed so bad, that instead of just crashing the simulator it closed every single chrome window (i was running it on chrome) on my comeputer, even windows from other accounts. Please answer this:

_Poll ([view on site](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/6))_

---

<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:** [March 16, 2026, 6:02pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/7 "2026-03-16T18:02:01Z")

</div>

I guess I could probably expand on what I said earlier: I am taking a wav file, running it through SPEAR to generate an sdif file (an SDIF file contains “partials” of a sound file, if you use SPEAR it is all the lines you see after uploading). I then use some c++ code to parse it (NOT what I want to add to makecode) and generate a number[]. Makecode can play it, using a loop and music.playInstructions(). this is the sound project (2 seconds of megalovania):

> **[2 seconds of megalovania](https://arcade.makecode.com/S99039-28239-13469-64746)**
>
> first measure of megalovania, has glitches of some sort though :ᗡ

it is very glitchy, and sometimes makecode will crash because it’s playing so many partials. I was thinking that if I could access the c++ it would be possible to somehow create my own music.playInstructions(), and it would sound better. reducing the partials would make it sound worse, so I’m not doing that

---

<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:** [March 16, 2026, 7:55pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/8 "2026-03-16T19:55:01Z")

</div>

@VoxelMaster64 I’ve moved these posts into their own thread so that they don’t get lost in the just chatting milieu.

no, there is no way to upload data files into makecode but there is a much more efficient way to include them in your program. see this post where i gave a sample script for converting number arrays into hex buffers:

> [@star SAMMY: Text-To-Speech / Speech Synthesizer Extension!](https://forum.makecode.com/t/sammy-text-to-speech-speech-synthesizer-extension/39499/39):
>
> if the data you’re including in your extension is lots of number arrays, then you should absolutely use buffers instead. they are way more efficient than arrays in terms of both memory usage and code size. however, if your data is a bunch of strings or images then you probably won’t gain anything by converting them to hex buffers. here’s a little bit of code to get you started if you do have some number arrays you want to convert. this code will convert a number array into the string representa…

as for what you want to do, i’d say that if you wanted to edit the C++ then you might be better off adding straight up sample playback rather than doing some waveform trickery to better approximate the sound. then you could write a script to convert your sample to PCM data and have the C++ code play that back.

we do have sample playback implemented in some of our other targets (micro:bit) it just hasn’t made its way to arcade yet.

---

<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:** [March 16, 2026, 11:38pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/9 "2026-03-16T23:38:05Z")

</div>

I was totally not expecting this to become another post.

If I fork the github repo(s) that make makecode run, if I get them into visual studio and have node.js, can I run makecode on vs and edit the code? Im a little confused, but would I then show you the changes I made to add sound playing?

I would like a little help if that’s possible, and if so, what github repo(s) I need to fork

---

<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:** [March 16, 2026, 11:46pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/10 "2026-03-16T23:46:54Z")

</div>

alright, fair warning: makecode is a very complex project and i would not recommend doing this unless you have some experience working with microcontrollers and webapps. with that out of the way, i don’t think i’ll be able to walk you through the entire process, but in general here is what i recommend:

1. Install VS Code
2. Install node.js (or node version manager)
3. Install [git](https://git-scm.com/)

open up a terminal (or command prompt on windows) and run these commands to set up your dev environment (note, this will probably take a while)

```bash
npm install -g pxt
mkdir makecode
cd makecode

git clone https://github.com/microsoft/pxt.git
cd pxt
npm install
npx gulp

cd ..
git clone https://github.com/microsoft/pxt-common-packages.git
cd pxt-common-packages
npm install
npm link ../pxt

cd ..
git clone https://github.com/microsoft/pxt-arcade.git
cd pxt-arcade
npm install
npm link ../pxt ../pxt-common-packages

```

once you’ve done that, you can run makecode arcade locally by running `pxt serve` from within pxt-arcade.

---

<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:** [March 19, 2026, 4:38pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/11 "2026-03-19T16:38:54Z")

</div>

which versions of git, node.js, and vs code should I use?

---

<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:** [March 19, 2026, 5:11pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/12 "2026-03-19T17:11:37Z")

</div>

for node, use something recent (i’m on v24) and always use the latest for git and vs code

if you use multiple versions of node, i highly recommend installing node version manager (or node version manager for windows if on windows)

---

<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:** [March 20, 2026, 12:27am UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/13 "2026-03-20T00:27:27Z")

</div>

When i run pxt serve, it opens makecode! This a great start to me. When i edit any code and want to test it, do i run this:

```auto
cd C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt
npm install
npm run build

cd ..\pxt-arcade
npm install
pxt serve

```

Also, what is something i should change to make sure its working? For example, it could be changing the

> Share Project

header in the share popup to

> This project will be shared when you press the Blue ‘Share Project’ Button at the bottom-right corner

---

<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:** [March 23, 2026, 4:56pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/14 "2026-03-23T16:56:34Z")

</div>

I should probably do this more:

@richard

yes, an @

---

<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:** [March 23, 2026, 4:59pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/15 "2026-03-23T16:59:53Z")

</div>

you don’t need to run `npm install` every time you make a change, and don’t run `npm install` in pxt-arcade because it will break the link you setup before. if you already did that, make sure to run this command from within pxt-arcade again:

```auto
npm link ../pxt ../pxt-common-packages

```

you are primarily going to be making changes in pxt-common-packages, so if you want to make sure your changes are working it might be easiest to just add a `console.log` to one of the files in `pxt-common-packages/libs/mixer` (which is where the audio code lives).

---

<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:** [April 6, 2026, 8:28pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/16 "2026-04-06T20:28:49Z")

</div>

@richard when I do finish, how should I send the audio function(s)?

---

<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:** [April 7, 2026, 4:55pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/17 "2026-04-07T16:55:34Z")

</div>

you should open pull requests on the repositories in github

---

<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:** [April 23, 2026, 4:52pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/18 "2026-04-23T16:52:22Z")

</div>

@richard so I am using my dad’s computer (Windows 11) to do add a pcm player. I am using the correct version of everything, and idk why it worked in the past, but it’s generating errors every time I run pxt-serve in pxt-arcade. I am aware that there was a time that the computer was restarted between the time it worked and the time it didn’t. I have also re-ran everything you gave me after putting the 3 pxt files into an “old” folder, so that everything was normal again. Copilot says that “npm link” is not generating symlinks, and that I need to enable developer mode.

> **Errors**
>
> There are 17 that look like this:
> 
> ```auto
> Error: Missing dependencies in config of: core
> at Object.userError (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:98994:25)
> at Package.validateConfig (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114061:23)
> at Package.parseConfig (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114305:18)
> at Package.loadAsync (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114364:22)
> at loadDepsRecursive (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114527:35)
> at Package.loadAsync (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114531:19)
> at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
> at async loadDepsRecursive (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114527:25)
> at async Package.loadAsync (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114531:13)
> at async loadDepsRecursive (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114527:25)
> at async Package.loadAsync (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114531:13)
> at async loadDepsRecursive (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114527:25)
> at async MainPackage.loadAsync (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:114531:13)
> at async Promise.all (index 0)
> at async buildTargetCoreAsync (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:165488:28)
> at async internalBuildTargetAsync (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:164585:9)
> at async buildTarget (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:165744:13)
> at async buildAndWatchTargetAsync (C:\Users\Dan\Desktop\miles\Cpp\makecode\pxt-arcade\node_modules\pxt-core\built\pxt.js:165776:5) {
> isUserError: true
> }
> 
> ```
> 
> And 7 that look like this:
> 
> ```auto
> keyboard.ts(281,13): error TS2304: Cannot find name 'game'.
> 
> ```

Before I actually turn on developer mode or anything, can you help or do you need more information?

---

<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:** [April 23, 2026, 4:55pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/19 "2026-04-23T16:55:07Z")

</div>

npm likes to remove symlinks when you run install again, you can recreate the symlinks like this:

```auto
npm link ../pxt ../pxt-common-packages

```

you shouldn’t need to have developer mode turned on (i don’t have it turned on)

make sure you do it all in one command like that.

---

<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:** [June 1, 2026, 5:26pm UTC](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721/20 "2026-06-01T17:26:13Z")

</div>

aaaghhglrwefgvgsajhvakjwfvbwkakerigilaergierakifrgedigreargifargefsiorfelgirfeligrefilreilrlieuseriufhesrfilhesruiflhseiulrlresiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

@richard finally got it to build correctly (i took a huge break btw). I thank Gemini for telling me to do things in PowerShell that I maybe should’ve been doing (theres a slight chance there was no change but I think it worked). Inside of pxt-common-packages:

```PowerShell
New-Item -ItemType SymbolicLink -Path ".\\node_modules\\pxt-core" -Target "..\\pxt"

```

instead of

```PowerShell
npm link ../pxt

```

Similar to pxt-arcade but

```PowerShell
New-Item -ItemType SymbolicLink -Path ".\node_modules\pxt-core" -Target "..\pxt"
New-Item -ItemType SymbolicLink -Path ".\node_modules\pxt-common-packages" -Target "..\pxt-common-packages"

```

Any tips on how to make the pcm sampling work, specifically how to shim things right? (where and how to shim enums and classes and functions and any other things, bc I think I need some kind of shim file along with a comment in the C++ and TypeScript objects)

also im doing the changes in `pxt-common-packages\libs\mixer\melody.cpp` and `melody.h`, is that correct?

[Next page](https://forum.makecode.com/t/questions-about-makecode-c-sound/42721.md?page=2)
