Skip to content
/ p1 Public

1kb piano music player from a string of notes.

Notifications You must be signed in to change notification settings

curtastic/p1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

dac8f5e · Sep 1, 2023

History

17 Commits
Aug 26, 2023
Aug 20, 2023
Aug 20, 2023
Sep 1, 2023
Sep 1, 2023

Repository files navigation

p1

Piano music player from a string of notes. 850 bytes minified.

There is only 1 function: p1 You can call it without parenthesis.

FULL EXAMPLE, PLAY JINGLE BELLS:

<html>
	<body>
		<script src="p1.js"></script>
		<button onclick="p1`c-c-c---|c-c-c---|c-f-Y--a|c-------|d-d-d--d|d-c-c-cc|f-f-d-a-|Y---f---`">
			Jingle Bells ▶
		</button>
	</body>
</html>

Try it! https://curtastic.com/p1/demo.html

TO STOP:

p1``

WITH BASS TRACK:

p1`
|V-Y-c-V-|d---c-a-|
|M-------|R-------|
`

Bass track can be shorter and will repeat.

WITH CUSTOM TEMPO (in milliseconds per note):

p1`70
V-Y-c-V-d---c-a-
M-------R-------`

WITH NOTES HELD DOWN LESS LONG = 30 (0 to 100, default is 50):

p1`70.30
V-Y-c-V-d---c-a-
M-------R-------`

Vertical bars are ingored and don't do anything.

Dashes make the note held longer.

Spaces are silent space.

Supports 52 notes (4 octaves) How to convert from piano notes to p1 letters:

|Low C      |Tenor C    |Middle C   |Treble C   |High C
C#D#EF#G#A#BC#D#EF#G#A#BC#D#EF#G#A#BC#D#EF#G#A#BC#D#
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

conversion table from piano notes to p1 letters

CREDITS:

xem: Piano systhesis and modulation code.

vertfromage: Simplified code and explanation.

About

1kb piano music player from a string of notes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published