In a massive studio above Manhattan's Fifth Avenue, Dan Tepfer is up late working on his next solo record.
"I'm gonna be here probably most of the night," he told AAP.
For the pioneering French American jazz pianist, playing solo is a more complicated idea than one might think.
Tepfer, a coder as well as a musician, has created a series of algorithms so his piano can play automatically alongside him, responding to his improvisations in real time.
He hooks up a Yamaha Disklavier - a modern version of the self-playing piano - to his computer, which registers his playing and generates thousands of lightning-fast lines of code, sending instructions back to the instrument.
"I basically created an improvisation partner with a computer and the way the computer expresses itself in sound is actually by playing the notes on the same Disklavier I'm playing," he said.
Tepfer's own improvisations are then shaped by these algorithmic responses until it's hard to tell where the musician ends and the machine begins.
Seeing the keys moving on their own in response to Tepfer's playing is strange and a little eerie, as though he is being accompanied by a virtuosic jazz ghost.
Having invested countless hours in practice, Tepfer said computers replacing musicians is the last thing he wants.
He argues he's still firmly in charge because, well, he made the rules.
"I don't think a computer should be too intelligent, I like a computer to augment a human's creativity," he said.
Tepfer has been working on the Disklavier project since 2014 and insists his ongoing explorations are not a technological gimmick but a means to fight complacency after more than three decades playing piano.
He released the acclaimed album of his experiments, titled Natural Machines, in 2018.
Tepfer will now bring the project to Melbourne's Planetarium in October, where the maths behind his music will also generate moving images projected onto the 16m planetarium dome.
These shows could be the ultimate intersection of all his considerable talents - he also has a degree in astrophysics and one of the algorithms he will deploy is built around the orbital ratios of planets.
"It'll be pretty trippy to do that in an actual planetarium," he enthused.
Tepfer hopes his experiments across jazz, coding and visual arts can reveal something of the mathematics of making music.
"We mostly will think of music as this kind of purely emotional thing, right? But actually, what makes the music great is that, mixed with the structure that's underneath," he said.
"The greatest works of art live at the intersection of the algorithmic and the spiritual."
Dan Tepfer plays at the Scienceworks Planetarium on Wednesday October 19 and Thursday October 20.
Melbourne International Jazz Festival is on from October 14-23.