pxt-core 8.5.8 → 8.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/pxt.js +83 -38
- package/built/pxtblockly.js +1 -1
- package/built/pxtblocks.js +1 -1
- package/built/pxtlib.d.ts +6 -1
- package/built/pxtlib.js +83 -38
- package/built/target.js +1 -1
- package/built/web/main.js +1 -1
- package/built/web/multiplayer/js/{main.838d2432.js → main.ec3fd68b.js} +2 -2
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtasseteditor.js +1 -1
- package/built/web/pxtblockly.js +1 -1
- package/built/web/pxtblocks.js +1 -1
- package/built/web/pxtembed.js +2 -2
- package/built/web/pxtlib.js +1 -1
- package/built/web/pxtworker.js +1 -1
- package/built/web/react-common-authcode.css +1 -1
- package/built/web/react-common-multiplayer.css +1 -1
- package/built/web/react-common-skillmap.css +1 -1
- package/built/web/rtlreact-common-authcode.css +1 -1
- package/built/web/rtlreact-common-multiplayer.css +1 -1
- package/built/web/rtlreact-common-skillmap.css +1 -1
- package/built/web/rtlsemantic.css +1 -1
- package/built/web/semantic.css +1 -1
- package/package.json +1 -1
- package/react-common/styles/controls/Checkbox.less +1 -0
- package/theme/asset-editor.less +6 -3
- package/theme/common.less +5 -2
- package/theme/music-editor/PlaybackControls.less +8 -2
- package/theme/tutorial-sidebar.less +0 -1
- package/webapp/public/multiplayer.html +1 -1
package/built/pxt.js
CHANGED
|
@@ -103491,7 +103491,7 @@ var pxt;
|
|
|
103491
103491
|
const DEV_BACKEND_PROD = "https://www.makecode.com";
|
|
103492
103492
|
const DEV_BACKEND_STAGING = "https://staging.pxt.io";
|
|
103493
103493
|
const DEV_BACKEND_LOCALHOST = "http://localhost:8080";
|
|
103494
|
-
cloud.DEV_BACKEND =
|
|
103494
|
+
cloud.DEV_BACKEND = DEV_BACKEND_STAGING;
|
|
103495
103495
|
function devBackendType() {
|
|
103496
103496
|
if (cloud.DEV_BACKEND === DEV_BACKEND_PROD)
|
|
103497
103497
|
return "prod";
|
|
@@ -111404,6 +111404,13 @@ var pxt;
|
|
|
111404
111404
|
(function (pxt) {
|
|
111405
111405
|
var multiplayer;
|
|
111406
111406
|
(function (multiplayer) {
|
|
111407
|
+
let MultiplayerDevBackendType;
|
|
111408
|
+
(function (MultiplayerDevBackendType) {
|
|
111409
|
+
MultiplayerDevBackendType[MultiplayerDevBackendType["PROD"] = 0] = "PROD";
|
|
111410
|
+
MultiplayerDevBackendType[MultiplayerDevBackendType["STAGING"] = 1] = "STAGING";
|
|
111411
|
+
MultiplayerDevBackendType[MultiplayerDevBackendType["LOCAL"] = 2] = "LOCAL";
|
|
111412
|
+
})(MultiplayerDevBackendType || (MultiplayerDevBackendType = {}));
|
|
111413
|
+
let MULTIPLAYER_DEV_BACKEND_TYPE = MultiplayerDevBackendType.STAGING;
|
|
111407
111414
|
multiplayer.SHORT_LINKS = {
|
|
111408
111415
|
PROD: "https://aka.ms/a9",
|
|
111409
111416
|
PROD_BETA: "https://aka.ms/a9b",
|
|
@@ -111413,12 +111420,12 @@ var pxt;
|
|
|
111413
111420
|
};
|
|
111414
111421
|
multiplayer.SHORT_LINK = () => {
|
|
111415
111422
|
if (pxt.BrowserUtils.isLocalHostDev()) {
|
|
111416
|
-
switch (
|
|
111417
|
-
case
|
|
111423
|
+
switch (MULTIPLAYER_DEV_BACKEND_TYPE) {
|
|
111424
|
+
case MultiplayerDevBackendType.PROD:
|
|
111418
111425
|
return multiplayer.SHORT_LINKS.PROD_BETA;
|
|
111419
|
-
case
|
|
111426
|
+
case MultiplayerDevBackendType.STAGING:
|
|
111420
111427
|
return multiplayer.SHORT_LINKS.STAGING_BETA;
|
|
111421
|
-
case
|
|
111428
|
+
case MultiplayerDevBackendType.LOCAL:
|
|
111422
111429
|
return multiplayer.SHORT_LINKS.LOCAL;
|
|
111423
111430
|
}
|
|
111424
111431
|
}
|
|
@@ -111685,7 +111692,7 @@ var pxt;
|
|
|
111685
111692
|
* notes byte length
|
|
111686
111693
|
* ...note events
|
|
111687
111694
|
*
|
|
111688
|
-
* instrument(
|
|
111695
|
+
* instrument(28 bytes)
|
|
111689
111696
|
* 0 waveform
|
|
111690
111697
|
* 1 amp attack
|
|
111691
111698
|
* 3 amp decay
|
|
@@ -111701,6 +111708,7 @@ var pxt;
|
|
|
111701
111708
|
* 22 amp lfo amp
|
|
111702
111709
|
* 24 pitch lfo freq
|
|
111703
111710
|
* 25 pitch lfo amp
|
|
111711
|
+
* 27 octave
|
|
111704
111712
|
*
|
|
111705
111713
|
* drum(5 + 7 * steps bytes)
|
|
111706
111714
|
* 0 steps
|
|
@@ -111720,6 +111728,12 @@ var pxt;
|
|
|
111720
111728
|
* 4 polyphony
|
|
111721
111729
|
* 5...notes(1 byte each)
|
|
111722
111730
|
*
|
|
111731
|
+
* note (1 byte)
|
|
111732
|
+
* lower six bits = note - (instrumentOctave - 2) * 12
|
|
111733
|
+
* upper two bits are the enharmonic spelling:
|
|
111734
|
+
* 0 = normal
|
|
111735
|
+
* 1 = flat
|
|
111736
|
+
* 2 = sharp
|
|
111723
111737
|
*/
|
|
111724
111738
|
function encodeSong(song) {
|
|
111725
111739
|
const encodedTracks = song.tracks
|
|
@@ -111774,6 +111788,7 @@ var pxt;
|
|
|
111774
111788
|
set16BitNumber(out, 22, ((_g = instrument.ampLFO) === null || _g === void 0 ? void 0 : _g.amplitude) || 0);
|
|
111775
111789
|
out[24] = ((_h = instrument.pitchLFO) === null || _h === void 0 ? void 0 : _h.frequency) || 0;
|
|
111776
111790
|
set16BitNumber(out, 25, ((_j = instrument.pitchLFO) === null || _j === void 0 ? void 0 : _j.amplitude) || 0);
|
|
111791
|
+
out[27] = instrument.octave;
|
|
111777
111792
|
return out;
|
|
111778
111793
|
}
|
|
111779
111794
|
function decodeInstrument(buf, offset) {
|
|
@@ -111800,7 +111815,8 @@ var pxt;
|
|
|
111800
111815
|
pitchLFO: {
|
|
111801
111816
|
frequency: buf[offset + 24],
|
|
111802
111817
|
amplitude: get16BitNumber(buf, 25)
|
|
111803
|
-
}
|
|
111818
|
+
},
|
|
111819
|
+
octave: buf[offset + 27]
|
|
111804
111820
|
};
|
|
111805
111821
|
}
|
|
111806
111822
|
function decodeTrack(buf, offset) {
|
|
@@ -111840,27 +111856,54 @@ var pxt;
|
|
|
111840
111856
|
}
|
|
111841
111857
|
return res;
|
|
111842
111858
|
}
|
|
111843
|
-
function encodeNoteEvent(event) {
|
|
111859
|
+
function encodeNoteEvent(event, instrumentOctave, isDrumTrack) {
|
|
111844
111860
|
const out = new Uint8Array(5 + event.notes.length);
|
|
111845
111861
|
set16BitNumber(out, 0, event.startTick);
|
|
111846
111862
|
set16BitNumber(out, 2, event.endTick);
|
|
111847
111863
|
out[4] = event.notes.length;
|
|
111848
111864
|
for (let i = 0; i < event.notes.length; i++) {
|
|
111849
|
-
out[5 + i] = event.notes[i];
|
|
111865
|
+
out[5 + i] = encodeNote(event.notes[i], instrumentOctave, isDrumTrack);
|
|
111850
111866
|
}
|
|
111851
111867
|
return out;
|
|
111852
111868
|
}
|
|
111853
|
-
function decodeNoteEvent(buf, offset) {
|
|
111869
|
+
function decodeNoteEvent(buf, offset, instrumentOctave, isDrumTrack) {
|
|
111854
111870
|
const res = {
|
|
111855
111871
|
startTick: get16BitNumber(buf, offset),
|
|
111856
111872
|
endTick: get16BitNumber(buf, offset + 2),
|
|
111857
111873
|
notes: []
|
|
111858
111874
|
};
|
|
111859
111875
|
for (let i = 0; i < buf[offset + 4]; i++) {
|
|
111860
|
-
res.notes.push(buf[offset + 5 + i]);
|
|
111876
|
+
res.notes.push(decodeNote(buf[offset + 5 + i], instrumentOctave, isDrumTrack));
|
|
111861
111877
|
}
|
|
111862
111878
|
return res;
|
|
111863
111879
|
}
|
|
111880
|
+
function encodeNote(note, instrumentOctave, isDrumTrack) {
|
|
111881
|
+
if (isDrumTrack) {
|
|
111882
|
+
return note.note;
|
|
111883
|
+
}
|
|
111884
|
+
let flags = 0;
|
|
111885
|
+
if (note.enharmonicSpelling === "flat") {
|
|
111886
|
+
flags = 1;
|
|
111887
|
+
}
|
|
111888
|
+
else if (note.enharmonicSpelling === "sharp") {
|
|
111889
|
+
flags = 2;
|
|
111890
|
+
}
|
|
111891
|
+
return (note.note - (instrumentOctave - 2) * 12) | (flags << 6);
|
|
111892
|
+
}
|
|
111893
|
+
function decodeNote(note, instrumentOctave, isDrumTrack) {
|
|
111894
|
+
const flags = note >> 6;
|
|
111895
|
+
const result = {
|
|
111896
|
+
note: isDrumTrack ? note : ((note & 0x3f) + (instrumentOctave - 2) * 12),
|
|
111897
|
+
enharmonicSpelling: "normal"
|
|
111898
|
+
};
|
|
111899
|
+
if (flags === 1) {
|
|
111900
|
+
result.enharmonicSpelling = "flat";
|
|
111901
|
+
}
|
|
111902
|
+
else if (flags === 2) {
|
|
111903
|
+
result.enharmonicSpelling = "sharp";
|
|
111904
|
+
}
|
|
111905
|
+
return result;
|
|
111906
|
+
}
|
|
111864
111907
|
function encodeTrack(track) {
|
|
111865
111908
|
if (track.drums)
|
|
111866
111909
|
return encodeDrumTrack(track);
|
|
@@ -111868,7 +111911,7 @@ var pxt;
|
|
|
111868
111911
|
}
|
|
111869
111912
|
function encodeMelodicTrack(track) {
|
|
111870
111913
|
const encodedInstrument = encodeInstrument(track.instrument);
|
|
111871
|
-
const encodedNotes = track.notes.map(encodeNoteEvent);
|
|
111914
|
+
const encodedNotes = track.notes.map(note => encodeNoteEvent(note, track.instrument.octave, false));
|
|
111872
111915
|
const noteLength = encodedNotes.reduce((d, c) => c.length + d, 0);
|
|
111873
111916
|
const out = new Uint8Array(6 + encodedInstrument.length + noteLength);
|
|
111874
111917
|
out[0] = track.id;
|
|
@@ -111895,7 +111938,7 @@ var pxt;
|
|
|
111895
111938
|
const noteLength = get16BitNumber(buf, noteStart);
|
|
111896
111939
|
let currentOffset = noteStart + 2;
|
|
111897
111940
|
while (currentOffset < noteStart + 2 + noteLength) {
|
|
111898
|
-
res.notes.push(decodeNoteEvent(buf, currentOffset));
|
|
111941
|
+
res.notes.push(decodeNoteEvent(buf, currentOffset, res.instrument.octave, false));
|
|
111899
111942
|
currentOffset += 5 + res.notes[res.notes.length - 1].notes.length;
|
|
111900
111943
|
}
|
|
111901
111944
|
return [res, currentOffset];
|
|
@@ -111903,7 +111946,7 @@ var pxt;
|
|
|
111903
111946
|
function encodeDrumTrack(track) {
|
|
111904
111947
|
const encodedDrums = track.drums.map(encodeDrumInstrument);
|
|
111905
111948
|
const drumLength = encodedDrums.reduce((d, c) => c.length + d, 0);
|
|
111906
|
-
const encodedNotes = track.notes.map(encodeNoteEvent);
|
|
111949
|
+
const encodedNotes = track.notes.map(note => encodeNoteEvent(note, 0, true));
|
|
111907
111950
|
const noteLength = encodedNotes.reduce((d, c) => c.length + d, 0);
|
|
111908
111951
|
const out = new Uint8Array(6 + drumLength + noteLength);
|
|
111909
111952
|
out[0] = track.id;
|
|
@@ -111938,7 +111981,7 @@ var pxt;
|
|
|
111938
111981
|
const noteLength = get16BitNumber(buf, currentOffset);
|
|
111939
111982
|
currentOffset += 2;
|
|
111940
111983
|
while (currentOffset < offset + 4 + drumByteLength + noteLength) {
|
|
111941
|
-
res.notes.push(decodeNoteEvent(buf, currentOffset));
|
|
111984
|
+
res.notes.push(decodeNoteEvent(buf, currentOffset, 0, true));
|
|
111942
111985
|
currentOffset += 5 + res.notes[res.notes.length - 1].notes.length;
|
|
111943
111986
|
}
|
|
111944
111987
|
return [res, currentOffset];
|
|
@@ -112005,6 +112048,27 @@ var pxt;
|
|
|
112005
112048
|
tracks: [
|
|
112006
112049
|
{
|
|
112007
112050
|
id: 0,
|
|
112051
|
+
name: lf("Dog"),
|
|
112052
|
+
notes: [],
|
|
112053
|
+
iconURI: "/static/music-editor/dog.png",
|
|
112054
|
+
instrument: {
|
|
112055
|
+
waveform: 1,
|
|
112056
|
+
octave: 4,
|
|
112057
|
+
ampEnvelope: {
|
|
112058
|
+
attack: 10,
|
|
112059
|
+
decay: 100,
|
|
112060
|
+
sustain: 500,
|
|
112061
|
+
release: 100,
|
|
112062
|
+
amplitude: 1024
|
|
112063
|
+
},
|
|
112064
|
+
pitchLFO: {
|
|
112065
|
+
frequency: 5,
|
|
112066
|
+
amplitude: 0
|
|
112067
|
+
}
|
|
112068
|
+
}
|
|
112069
|
+
},
|
|
112070
|
+
{
|
|
112071
|
+
id: 1,
|
|
112008
112072
|
name: lf("Duck"),
|
|
112009
112073
|
notes: [],
|
|
112010
112074
|
iconURI: "/static/music-editor/duck.png",
|
|
@@ -112036,7 +112100,7 @@ var pxt;
|
|
|
112036
112100
|
}
|
|
112037
112101
|
},
|
|
112038
112102
|
{
|
|
112039
|
-
id:
|
|
112103
|
+
id: 2,
|
|
112040
112104
|
name: lf("Cat"),
|
|
112041
112105
|
notes: [],
|
|
112042
112106
|
iconURI: "/static/music-editor/cat.png",
|
|
@@ -112063,27 +112127,6 @@ var pxt;
|
|
|
112063
112127
|
}
|
|
112064
112128
|
}
|
|
112065
112129
|
},
|
|
112066
|
-
{
|
|
112067
|
-
id: 2,
|
|
112068
|
-
name: lf("Dog"),
|
|
112069
|
-
notes: [],
|
|
112070
|
-
iconURI: "/static/music-editor/dog.png",
|
|
112071
|
-
instrument: {
|
|
112072
|
-
waveform: 1,
|
|
112073
|
-
octave: 4,
|
|
112074
|
-
ampEnvelope: {
|
|
112075
|
-
attack: 10,
|
|
112076
|
-
decay: 100,
|
|
112077
|
-
sustain: 500,
|
|
112078
|
-
release: 100,
|
|
112079
|
-
amplitude: 1024
|
|
112080
|
-
},
|
|
112081
|
-
pitchLFO: {
|
|
112082
|
-
frequency: 5,
|
|
112083
|
-
amplitude: 0
|
|
112084
|
-
}
|
|
112085
|
-
}
|
|
112086
|
-
},
|
|
112087
112130
|
{
|
|
112088
112131
|
id: 3,
|
|
112089
112132
|
name: lf("Fish"),
|
|
@@ -117267,6 +117310,7 @@ var pxt;
|
|
|
117267
117310
|
const isProject = dep.id === "this";
|
|
117268
117311
|
const images = this.readImages(dep.parseJRes(), isProject);
|
|
117269
117312
|
for (const image of images) {
|
|
117313
|
+
image.meta.package = dep.id;
|
|
117270
117314
|
if (image.type === "tile" /* AssetType.Tile */) {
|
|
117271
117315
|
if (isProject) {
|
|
117272
117316
|
this.state.tiles.add(image);
|
|
@@ -117308,7 +117352,8 @@ var pxt;
|
|
|
117308
117352
|
id: tm.id,
|
|
117309
117353
|
meta: {
|
|
117310
117354
|
// For tilemaps, use the id as the display name for backwards compat
|
|
117311
|
-
displayName: tm.displayName || tm.id
|
|
117355
|
+
displayName: tm.displayName || tm.id,
|
|
117356
|
+
package: pack.id
|
|
117312
117357
|
},
|
|
117313
117358
|
data: decodeTilemap(tm, id => this.resolveTile(id))
|
|
117314
117359
|
});
|
package/built/pxtblockly.js
CHANGED
|
@@ -17365,7 +17365,7 @@ var pxtblockly;
|
|
|
17365
17365
|
if (col > cellsShown)
|
|
17366
17366
|
break;
|
|
17367
17367
|
for (const note of noteEvent.notes) {
|
|
17368
|
-
const row = 12 - (note % 12);
|
|
17368
|
+
const row = 12 - (note.note % 12);
|
|
17369
17369
|
if (row > notesShown)
|
|
17370
17370
|
continue;
|
|
17371
17371
|
context.fillStyle = colors[trackColors[track.id || song.tracks.indexOf(track)]];
|
package/built/pxtblocks.js
CHANGED
|
@@ -13803,7 +13803,7 @@ var pxtblockly;
|
|
|
13803
13803
|
if (col > cellsShown)
|
|
13804
13804
|
break;
|
|
13805
13805
|
for (const note of noteEvent.notes) {
|
|
13806
|
-
const row = 12 - (note % 12);
|
|
13806
|
+
const row = 12 - (note.note % 12);
|
|
13807
13807
|
if (row > notesShown)
|
|
13808
13808
|
continue;
|
|
13809
13809
|
context.fillStyle = colors[trackColors[track.id || song.tracks.indexOf(track)]];
|
package/built/pxtlib.d.ts
CHANGED
|
@@ -1829,10 +1829,14 @@ declare namespace pxt.assets.music {
|
|
|
1829
1829
|
notes: NoteEvent[];
|
|
1830
1830
|
}
|
|
1831
1831
|
interface NoteEvent {
|
|
1832
|
-
notes:
|
|
1832
|
+
notes: Note[];
|
|
1833
1833
|
startTick: number;
|
|
1834
1834
|
endTick: number;
|
|
1835
1835
|
}
|
|
1836
|
+
interface Note {
|
|
1837
|
+
note: number;
|
|
1838
|
+
enharmonicSpelling: "normal" | "flat" | "sharp";
|
|
1839
|
+
}
|
|
1836
1840
|
interface DrumSoundStep {
|
|
1837
1841
|
waveform: number;
|
|
1838
1842
|
frequency: number;
|
|
@@ -2713,6 +2717,7 @@ declare namespace pxt {
|
|
|
2713
2717
|
tags?: string[];
|
|
2714
2718
|
blockIDs?: string[];
|
|
2715
2719
|
temporaryInfo?: TemporaryAssetInfo;
|
|
2720
|
+
package?: string;
|
|
2716
2721
|
}
|
|
2717
2722
|
export interface TemporaryAssetInfo {
|
|
2718
2723
|
blockId: string;
|
package/built/pxtlib.js
CHANGED
|
@@ -5805,7 +5805,7 @@ var pxt;
|
|
|
5805
5805
|
const DEV_BACKEND_PROD = "https://www.makecode.com";
|
|
5806
5806
|
const DEV_BACKEND_STAGING = "https://staging.pxt.io";
|
|
5807
5807
|
const DEV_BACKEND_LOCALHOST = "http://localhost:8080";
|
|
5808
|
-
cloud.DEV_BACKEND =
|
|
5808
|
+
cloud.DEV_BACKEND = DEV_BACKEND_STAGING;
|
|
5809
5809
|
function devBackendType() {
|
|
5810
5810
|
if (cloud.DEV_BACKEND === DEV_BACKEND_PROD)
|
|
5811
5811
|
return "prod";
|
|
@@ -13718,6 +13718,13 @@ var pxt;
|
|
|
13718
13718
|
(function (pxt) {
|
|
13719
13719
|
var multiplayer;
|
|
13720
13720
|
(function (multiplayer) {
|
|
13721
|
+
let MultiplayerDevBackendType;
|
|
13722
|
+
(function (MultiplayerDevBackendType) {
|
|
13723
|
+
MultiplayerDevBackendType[MultiplayerDevBackendType["PROD"] = 0] = "PROD";
|
|
13724
|
+
MultiplayerDevBackendType[MultiplayerDevBackendType["STAGING"] = 1] = "STAGING";
|
|
13725
|
+
MultiplayerDevBackendType[MultiplayerDevBackendType["LOCAL"] = 2] = "LOCAL";
|
|
13726
|
+
})(MultiplayerDevBackendType || (MultiplayerDevBackendType = {}));
|
|
13727
|
+
let MULTIPLAYER_DEV_BACKEND_TYPE = MultiplayerDevBackendType.STAGING;
|
|
13721
13728
|
multiplayer.SHORT_LINKS = {
|
|
13722
13729
|
PROD: "https://aka.ms/a9",
|
|
13723
13730
|
PROD_BETA: "https://aka.ms/a9b",
|
|
@@ -13727,12 +13734,12 @@ var pxt;
|
|
|
13727
13734
|
};
|
|
13728
13735
|
multiplayer.SHORT_LINK = () => {
|
|
13729
13736
|
if (pxt.BrowserUtils.isLocalHostDev()) {
|
|
13730
|
-
switch (
|
|
13731
|
-
case
|
|
13737
|
+
switch (MULTIPLAYER_DEV_BACKEND_TYPE) {
|
|
13738
|
+
case MultiplayerDevBackendType.PROD:
|
|
13732
13739
|
return multiplayer.SHORT_LINKS.PROD_BETA;
|
|
13733
|
-
case
|
|
13740
|
+
case MultiplayerDevBackendType.STAGING:
|
|
13734
13741
|
return multiplayer.SHORT_LINKS.STAGING_BETA;
|
|
13735
|
-
case
|
|
13742
|
+
case MultiplayerDevBackendType.LOCAL:
|
|
13736
13743
|
return multiplayer.SHORT_LINKS.LOCAL;
|
|
13737
13744
|
}
|
|
13738
13745
|
}
|
|
@@ -13999,7 +14006,7 @@ var pxt;
|
|
|
13999
14006
|
* notes byte length
|
|
14000
14007
|
* ...note events
|
|
14001
14008
|
*
|
|
14002
|
-
* instrument(
|
|
14009
|
+
* instrument(28 bytes)
|
|
14003
14010
|
* 0 waveform
|
|
14004
14011
|
* 1 amp attack
|
|
14005
14012
|
* 3 amp decay
|
|
@@ -14015,6 +14022,7 @@ var pxt;
|
|
|
14015
14022
|
* 22 amp lfo amp
|
|
14016
14023
|
* 24 pitch lfo freq
|
|
14017
14024
|
* 25 pitch lfo amp
|
|
14025
|
+
* 27 octave
|
|
14018
14026
|
*
|
|
14019
14027
|
* drum(5 + 7 * steps bytes)
|
|
14020
14028
|
* 0 steps
|
|
@@ -14034,6 +14042,12 @@ var pxt;
|
|
|
14034
14042
|
* 4 polyphony
|
|
14035
14043
|
* 5...notes(1 byte each)
|
|
14036
14044
|
*
|
|
14045
|
+
* note (1 byte)
|
|
14046
|
+
* lower six bits = note - (instrumentOctave - 2) * 12
|
|
14047
|
+
* upper two bits are the enharmonic spelling:
|
|
14048
|
+
* 0 = normal
|
|
14049
|
+
* 1 = flat
|
|
14050
|
+
* 2 = sharp
|
|
14037
14051
|
*/
|
|
14038
14052
|
function encodeSong(song) {
|
|
14039
14053
|
const encodedTracks = song.tracks
|
|
@@ -14088,6 +14102,7 @@ var pxt;
|
|
|
14088
14102
|
set16BitNumber(out, 22, ((_g = instrument.ampLFO) === null || _g === void 0 ? void 0 : _g.amplitude) || 0);
|
|
14089
14103
|
out[24] = ((_h = instrument.pitchLFO) === null || _h === void 0 ? void 0 : _h.frequency) || 0;
|
|
14090
14104
|
set16BitNumber(out, 25, ((_j = instrument.pitchLFO) === null || _j === void 0 ? void 0 : _j.amplitude) || 0);
|
|
14105
|
+
out[27] = instrument.octave;
|
|
14091
14106
|
return out;
|
|
14092
14107
|
}
|
|
14093
14108
|
function decodeInstrument(buf, offset) {
|
|
@@ -14114,7 +14129,8 @@ var pxt;
|
|
|
14114
14129
|
pitchLFO: {
|
|
14115
14130
|
frequency: buf[offset + 24],
|
|
14116
14131
|
amplitude: get16BitNumber(buf, 25)
|
|
14117
|
-
}
|
|
14132
|
+
},
|
|
14133
|
+
octave: buf[offset + 27]
|
|
14118
14134
|
};
|
|
14119
14135
|
}
|
|
14120
14136
|
function decodeTrack(buf, offset) {
|
|
@@ -14154,27 +14170,54 @@ var pxt;
|
|
|
14154
14170
|
}
|
|
14155
14171
|
return res;
|
|
14156
14172
|
}
|
|
14157
|
-
function encodeNoteEvent(event) {
|
|
14173
|
+
function encodeNoteEvent(event, instrumentOctave, isDrumTrack) {
|
|
14158
14174
|
const out = new Uint8Array(5 + event.notes.length);
|
|
14159
14175
|
set16BitNumber(out, 0, event.startTick);
|
|
14160
14176
|
set16BitNumber(out, 2, event.endTick);
|
|
14161
14177
|
out[4] = event.notes.length;
|
|
14162
14178
|
for (let i = 0; i < event.notes.length; i++) {
|
|
14163
|
-
out[5 + i] = event.notes[i];
|
|
14179
|
+
out[5 + i] = encodeNote(event.notes[i], instrumentOctave, isDrumTrack);
|
|
14164
14180
|
}
|
|
14165
14181
|
return out;
|
|
14166
14182
|
}
|
|
14167
|
-
function decodeNoteEvent(buf, offset) {
|
|
14183
|
+
function decodeNoteEvent(buf, offset, instrumentOctave, isDrumTrack) {
|
|
14168
14184
|
const res = {
|
|
14169
14185
|
startTick: get16BitNumber(buf, offset),
|
|
14170
14186
|
endTick: get16BitNumber(buf, offset + 2),
|
|
14171
14187
|
notes: []
|
|
14172
14188
|
};
|
|
14173
14189
|
for (let i = 0; i < buf[offset + 4]; i++) {
|
|
14174
|
-
res.notes.push(buf[offset + 5 + i]);
|
|
14190
|
+
res.notes.push(decodeNote(buf[offset + 5 + i], instrumentOctave, isDrumTrack));
|
|
14175
14191
|
}
|
|
14176
14192
|
return res;
|
|
14177
14193
|
}
|
|
14194
|
+
function encodeNote(note, instrumentOctave, isDrumTrack) {
|
|
14195
|
+
if (isDrumTrack) {
|
|
14196
|
+
return note.note;
|
|
14197
|
+
}
|
|
14198
|
+
let flags = 0;
|
|
14199
|
+
if (note.enharmonicSpelling === "flat") {
|
|
14200
|
+
flags = 1;
|
|
14201
|
+
}
|
|
14202
|
+
else if (note.enharmonicSpelling === "sharp") {
|
|
14203
|
+
flags = 2;
|
|
14204
|
+
}
|
|
14205
|
+
return (note.note - (instrumentOctave - 2) * 12) | (flags << 6);
|
|
14206
|
+
}
|
|
14207
|
+
function decodeNote(note, instrumentOctave, isDrumTrack) {
|
|
14208
|
+
const flags = note >> 6;
|
|
14209
|
+
const result = {
|
|
14210
|
+
note: isDrumTrack ? note : ((note & 0x3f) + (instrumentOctave - 2) * 12),
|
|
14211
|
+
enharmonicSpelling: "normal"
|
|
14212
|
+
};
|
|
14213
|
+
if (flags === 1) {
|
|
14214
|
+
result.enharmonicSpelling = "flat";
|
|
14215
|
+
}
|
|
14216
|
+
else if (flags === 2) {
|
|
14217
|
+
result.enharmonicSpelling = "sharp";
|
|
14218
|
+
}
|
|
14219
|
+
return result;
|
|
14220
|
+
}
|
|
14178
14221
|
function encodeTrack(track) {
|
|
14179
14222
|
if (track.drums)
|
|
14180
14223
|
return encodeDrumTrack(track);
|
|
@@ -14182,7 +14225,7 @@ var pxt;
|
|
|
14182
14225
|
}
|
|
14183
14226
|
function encodeMelodicTrack(track) {
|
|
14184
14227
|
const encodedInstrument = encodeInstrument(track.instrument);
|
|
14185
|
-
const encodedNotes = track.notes.map(encodeNoteEvent);
|
|
14228
|
+
const encodedNotes = track.notes.map(note => encodeNoteEvent(note, track.instrument.octave, false));
|
|
14186
14229
|
const noteLength = encodedNotes.reduce((d, c) => c.length + d, 0);
|
|
14187
14230
|
const out = new Uint8Array(6 + encodedInstrument.length + noteLength);
|
|
14188
14231
|
out[0] = track.id;
|
|
@@ -14209,7 +14252,7 @@ var pxt;
|
|
|
14209
14252
|
const noteLength = get16BitNumber(buf, noteStart);
|
|
14210
14253
|
let currentOffset = noteStart + 2;
|
|
14211
14254
|
while (currentOffset < noteStart + 2 + noteLength) {
|
|
14212
|
-
res.notes.push(decodeNoteEvent(buf, currentOffset));
|
|
14255
|
+
res.notes.push(decodeNoteEvent(buf, currentOffset, res.instrument.octave, false));
|
|
14213
14256
|
currentOffset += 5 + res.notes[res.notes.length - 1].notes.length;
|
|
14214
14257
|
}
|
|
14215
14258
|
return [res, currentOffset];
|
|
@@ -14217,7 +14260,7 @@ var pxt;
|
|
|
14217
14260
|
function encodeDrumTrack(track) {
|
|
14218
14261
|
const encodedDrums = track.drums.map(encodeDrumInstrument);
|
|
14219
14262
|
const drumLength = encodedDrums.reduce((d, c) => c.length + d, 0);
|
|
14220
|
-
const encodedNotes = track.notes.map(encodeNoteEvent);
|
|
14263
|
+
const encodedNotes = track.notes.map(note => encodeNoteEvent(note, 0, true));
|
|
14221
14264
|
const noteLength = encodedNotes.reduce((d, c) => c.length + d, 0);
|
|
14222
14265
|
const out = new Uint8Array(6 + drumLength + noteLength);
|
|
14223
14266
|
out[0] = track.id;
|
|
@@ -14252,7 +14295,7 @@ var pxt;
|
|
|
14252
14295
|
const noteLength = get16BitNumber(buf, currentOffset);
|
|
14253
14296
|
currentOffset += 2;
|
|
14254
14297
|
while (currentOffset < offset + 4 + drumByteLength + noteLength) {
|
|
14255
|
-
res.notes.push(decodeNoteEvent(buf, currentOffset));
|
|
14298
|
+
res.notes.push(decodeNoteEvent(buf, currentOffset, 0, true));
|
|
14256
14299
|
currentOffset += 5 + res.notes[res.notes.length - 1].notes.length;
|
|
14257
14300
|
}
|
|
14258
14301
|
return [res, currentOffset];
|
|
@@ -14319,6 +14362,27 @@ var pxt;
|
|
|
14319
14362
|
tracks: [
|
|
14320
14363
|
{
|
|
14321
14364
|
id: 0,
|
|
14365
|
+
name: lf("Dog"),
|
|
14366
|
+
notes: [],
|
|
14367
|
+
iconURI: "/static/music-editor/dog.png",
|
|
14368
|
+
instrument: {
|
|
14369
|
+
waveform: 1,
|
|
14370
|
+
octave: 4,
|
|
14371
|
+
ampEnvelope: {
|
|
14372
|
+
attack: 10,
|
|
14373
|
+
decay: 100,
|
|
14374
|
+
sustain: 500,
|
|
14375
|
+
release: 100,
|
|
14376
|
+
amplitude: 1024
|
|
14377
|
+
},
|
|
14378
|
+
pitchLFO: {
|
|
14379
|
+
frequency: 5,
|
|
14380
|
+
amplitude: 0
|
|
14381
|
+
}
|
|
14382
|
+
}
|
|
14383
|
+
},
|
|
14384
|
+
{
|
|
14385
|
+
id: 1,
|
|
14322
14386
|
name: lf("Duck"),
|
|
14323
14387
|
notes: [],
|
|
14324
14388
|
iconURI: "/static/music-editor/duck.png",
|
|
@@ -14350,7 +14414,7 @@ var pxt;
|
|
|
14350
14414
|
}
|
|
14351
14415
|
},
|
|
14352
14416
|
{
|
|
14353
|
-
id:
|
|
14417
|
+
id: 2,
|
|
14354
14418
|
name: lf("Cat"),
|
|
14355
14419
|
notes: [],
|
|
14356
14420
|
iconURI: "/static/music-editor/cat.png",
|
|
@@ -14377,27 +14441,6 @@ var pxt;
|
|
|
14377
14441
|
}
|
|
14378
14442
|
}
|
|
14379
14443
|
},
|
|
14380
|
-
{
|
|
14381
|
-
id: 2,
|
|
14382
|
-
name: lf("Dog"),
|
|
14383
|
-
notes: [],
|
|
14384
|
-
iconURI: "/static/music-editor/dog.png",
|
|
14385
|
-
instrument: {
|
|
14386
|
-
waveform: 1,
|
|
14387
|
-
octave: 4,
|
|
14388
|
-
ampEnvelope: {
|
|
14389
|
-
attack: 10,
|
|
14390
|
-
decay: 100,
|
|
14391
|
-
sustain: 500,
|
|
14392
|
-
release: 100,
|
|
14393
|
-
amplitude: 1024
|
|
14394
|
-
},
|
|
14395
|
-
pitchLFO: {
|
|
14396
|
-
frequency: 5,
|
|
14397
|
-
amplitude: 0
|
|
14398
|
-
}
|
|
14399
|
-
}
|
|
14400
|
-
},
|
|
14401
14444
|
{
|
|
14402
14445
|
id: 3,
|
|
14403
14446
|
name: lf("Fish"),
|
|
@@ -19581,6 +19624,7 @@ var pxt;
|
|
|
19581
19624
|
const isProject = dep.id === "this";
|
|
19582
19625
|
const images = this.readImages(dep.parseJRes(), isProject);
|
|
19583
19626
|
for (const image of images) {
|
|
19627
|
+
image.meta.package = dep.id;
|
|
19584
19628
|
if (image.type === "tile" /* AssetType.Tile */) {
|
|
19585
19629
|
if (isProject) {
|
|
19586
19630
|
this.state.tiles.add(image);
|
|
@@ -19622,7 +19666,8 @@ var pxt;
|
|
|
19622
19666
|
id: tm.id,
|
|
19623
19667
|
meta: {
|
|
19624
19668
|
// For tilemaps, use the id as the display name for backwards compat
|
|
19625
|
-
displayName: tm.displayName || tm.id
|
|
19669
|
+
displayName: tm.displayName || tm.id,
|
|
19670
|
+
package: pack.id
|
|
19626
19671
|
},
|
|
19627
19672
|
data: decodeTilemap(tm, id => this.resolveTile(id))
|
|
19628
19673
|
});
|