Music
Start a song
POST
/api/songOpen. Open to everyone who can reach Tempolight.
A song about to play in a browser, with its analysis (from preAnalyseCore() in /engine/analysis.js). With song memory on, songs over 20 s are remembered. Then send its clock.
Request body application/json
namestringanalysisobjectrequiredThe result of preAnalyseCore() from /engine/analysis.js; must have bpm.
clientIdstringThe WebSocket connection's id, from its hello message.
Responses
200OKapplication/json
oktruerequired400The body isn't valid JSON, or a value is wrong.application/json
errorstringrequiredWhat went wrong, in a sentence for people.
Request
curl -X POST 'http://localhost:8080/api/song' \
-H 'content-type: application/json' \
-d '{
"name": "My song.mp3",
"analysis": {
"bpm": 124,
"dur": 210.5
},
"clientId": "c3k9"
}'const res = await fetch("http://localhost:8080/api/song", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
"name": "My song.mp3",
"analysis": {
"bpm": 124,
"dur": 210.5
},
"clientId": "c3k9"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"http://localhost:8080/api/song",
json={
"name": "My song.mp3",
"analysis": {
"bpm": 124,
"dur": 210.5
},
"clientId": "c3k9"
},
)
print(res.json())Response
{
"ok": true
}{
"error": "Send the song's analysis"
}