Bleuzen / SpotRec

Spotify desktop client recorder for PulseAudio
MIT License
75 stars 17 forks source link

Hacky solution for more automatic/accurate track separation #4

Closed cgarz closed 5 years ago

cgarz commented 5 years ago

To allow greater automation for people who want to just set it and go, like myself. It's possible to make a playlist of all the songs you want with a silent track separating them.

You could then have an optional mode where you would read this as an end of track message and close ffmpeg.

This would also eliminate the pause > previous > play commands between each song. Simply start the next recording then send the next song command.

A nice 10 second example titled "Silent Track" from artist "Silent Track" is here: http://open.spotify.com/track/5XSKC4d0y0DfcGbvDOiL93?si=V6UuIOkYRl2XrJOzhVHlIA

However, since this would then just shift the tedium from post processing to playlist creation, I've found a lovely playlist creator with conditionals, combiners and other goodies: http://smarterplaylists.playlistmachinery.com/examples.html

I created a massive playlist of the silent track by continually copying its tracks into itself. I stopped at 8192. Then I used the "alternate" combiner to combine that playlist with my saved tracks. It stops once one list is exhausted. When run, it quickly spits out a nice silence gapped playlist =D.

What do you think?

Bleuzen commented 5 years ago

This would not work, because it is not possible for us to guess the next song. To start a new recording, we need the song name. We can only get the current playing songs name. So SpotRec would have to wait until next song starts playing to detect it's name. Since there is a little delay after song name detection, SpotRec goes to the beginning of the song again to not miss the first second in the recording. Currently the only way to go to the beginning is to pause and previous. No other way we could use rn. So this would not eliminate the need of this. -> Would make no sense to implement.

cgarz commented 5 years ago

Ah yes that would be another issue. SpotRec would need to write to a temp file and rename once done. Is that out of the question? If so, why?

Bleuzen commented 5 years ago

Not sure what it has to do with this, but to write to a temporary hidden file is already supported. Just pass -t as argument when starting SpotRec.

cgarz commented 5 years ago

Yes I saw that thanks. I actually enabled that option since I preferred it.

Sorry I'm still being unclear, what I mean in this case is that the temp file would no longer have the \<trackName>.flac format and would instead have a \<GenericName>.flac format. Then after recording is done you would rename the \<GenericName>.flac to \<trackName>.flac

The process would be as follows:

In this way entire playlists or saved track collections can be reliably recorded and will at worst contain a tiny bit of leading/trailing silence. Which is much easier to remove programatically in a batch process if needed.

Bleuzen commented 5 years ago

Yeah would be possible. But not today or tomorrow, because:

cgarz commented 5 years ago

I understand, it is a pretty niche thing with alot of setup required. I might try to make it myself to get all my saved songs. I'm not a great programmer though so it would probably be ugly.

Any suggestions how best to do it? For example where should I put the track info query and the renaming part?

Bleuzen commented 5 years ago

Hi, sorry for not answering, I missed your last message somehow. I will close this issue because nobody seems interrested in doing this. (You may still do it if you want.)

As a hint: If you want to listen to track changes, implement your code in the "playing_song_changed" method of the "Spotify" class. In this method you have acces to the new song (as shown in the log message there). You can use it to detect if it is the silent track.

cgarz commented 5 years ago

No worries I've been working on other things so didn't have a chance to try this yet anyway.

I would still like to try it though so thanks for the tip.