Skip to main content

Optimizing the length of a song

Full API reference

Now that you've got your song's foundation in place, it's time to optimize its length! To do this, make a POST request to the /optimizeSongLength endpoint with the following parameters:

POST /optimizeSongLength HTTP/1.1
Host: staging.casperaki.com
Content-Type: application/json

{
"targetSongLength": 3,
"modifier": "tempoAndSongStructure",
{
"style": "edm",
"tempo": "120",
"key": "A",
"songStructure": [
{
"segment": "intro",
"lengthInBars": 2
},
{
"segment": "verse1",
"lengthInBars": 4
},
{
"segment": "preChorus1",
"lengthInBars": 8
},
{
"segment": "preChorus1",
"lengthInBars": 8
},
{
"segment": "chorus1",
"lengthInBars": 16
},
{
"segment": "verse2",
"lengthInBars": 16
},
{
"segment": "preChorus2",
"lengthInBars": 8
},
{
"segment": "chorus2",
"lengthInBars": 16
},
{
"segment": "chorus3",
"lengthInBars": 16
}
]
}
}

This will give you an optimized song length based on your specified target song length and the provided song structure. You can use this API to create a unique sound that reflects your artistic vision.

Note: The targetSongLength parameter specifies the desired length of the final song, while the modifier parameter controls how the song's tempo and structure are adjusted to achieve this length. In this example, we're using a modifier of "tempoAndSongStructure" to optimize the song's tempo and structure based on its current values.