Public
Edited
Mar 29, 2023
Paused
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
analysis = (await api.getAudioAnalysisForTrack(currentPlayingTrack.item.id))
.body
Insert cell
currentPlayingTrack = {
return (await api.getMyCurrentPlayingTrack()).body;
}
Insert cell
tidySegments = analysis.segments.flatMap((segment) =>
segment.pitches.map((pitch, i) => ({
pitch_index: i,
pitch_value: pitch,
...segment
}))
)
Insert cell
updateRate = (1000 * 60) / analysis.track.tempo
Insert cell
Insert cell
loudnessMarks = [
Plot.tickX(analysis.bars, { x: "start", strokeOpacity: 0.3 }),
Plot.tickX(analysis.beats, { x: "start", strokeOpacity: 0.1 }),
Plot.line(analysis.segments, {
x: "start",
y: "loudness_start"
})
]
Insert cell
currentSegment = analysis.segments.find((segment) => segment.start > t / 1000)
Insert cell
Insert cell
getSegmentPitches(currentSegment)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
p5Sound = require("https://unpkg.com/p5@1.2.0/lib/addons/p5.sound.js").catch(
() => window["p5"]
)
Insert cell
<figure>
${await FileAttachment("image.png").image()}
</figure>
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more