musikr: expose bitrate and sample rate

This commit is contained in:
Alexander Capehart 2024-12-17 10:42:54 -05:00
parent 880967f8be
commit 50b7c24c03
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
6 changed files with 17 additions and 7 deletions

View file

@ -265,6 +265,10 @@ interface Song : Music {
val size: Long val size: Long
/** The duration of the audio file, in milliseconds. */ /** The duration of the audio file, in milliseconds. */
val durationMs: Long val durationMs: Long
/** The bitrate of the audio file, in kbps. */
val bitrateKbps: Int
/** The sample rate of the audio file, in Hz. */
val sampleRateHz: Int
/** The ReplayGain adjustment to apply during playback. */ /** The ReplayGain adjustment to apply during playback. */
val replayGainAdjustment: ReplayGainAdjustment val replayGainAdjustment: ReplayGainAdjustment
/** The date last modified the audio file was last modified, as a unix epoch timestamp. */ /** The date last modified the audio file was last modified, as a unix epoch timestamp. */

View file

@ -67,8 +67,8 @@ internal data class CachedSong(
val dateModified: Long, val dateModified: Long,
val mimeType: String, val mimeType: String,
val durationMs: Long, val durationMs: Long,
val bitrate: Int, val bitrateHz: Int,
val sampleRate: Int, val sampleRateHz: Int,
val musicBrainzId: String?, val musicBrainzId: String?,
val name: String, val name: String,
val sortName: String?, val sortName: String?,
@ -94,7 +94,7 @@ internal data class CachedSong(
fun intoRawSong(file: DeviceFile) = fun intoRawSong(file: DeviceFile) =
RawSong( RawSong(
file, file,
Properties(mimeType, durationMs, bitrate, sampleRate), Properties(mimeType, durationMs, bitrateHz, sampleRateHz),
ParsedTags( ParsedTags(
musicBrainzId = musicBrainzId, musicBrainzId = musicBrainzId,
name = name, name = name,
@ -164,7 +164,7 @@ internal data class CachedSong(
replayGainAlbumAdjustment = rawSong.tags.replayGainAlbumAdjustment, replayGainAlbumAdjustment = rawSong.tags.replayGainAlbumAdjustment,
cover = rawSong.cover, cover = rawSong.cover,
mimeType = rawSong.properties.mimeType, mimeType = rawSong.properties.mimeType,
bitrate = rawSong.properties.bitrate, bitrateHz = rawSong.properties.bitrateKbps,
sampleRate = rawSong.properties.sampleRate) sampleRateHz = rawSong.properties.sampleRateHz)
} }
} }

View file

@ -56,6 +56,6 @@ internal data class Metadata(
data class Properties( data class Properties(
val mimeType: String, val mimeType: String,
val durationMs: Long, val durationMs: Long,
val bitrate: Int, val bitrateKbps: Int,
val sampleRate: Int, val sampleRateHz: Int,
) )

View file

@ -52,6 +52,8 @@ internal class SongImpl(private val handle: SongCore) : Song {
override val format = preSong.format override val format = preSong.format
override val size = preSong.size override val size = preSong.size
override val durationMs = preSong.durationMs override val durationMs = preSong.durationMs
override val bitrateKbps = preSong.bitrateKbps
override val sampleRateHz = preSong.sampleRateHz
override val replayGainAdjustment = preSong.replayGainAdjustment override val replayGainAdjustment = preSong.replayGainAdjustment
override val lastModified = preSong.lastModified override val lastModified = preSong.lastModified
override val dateAdded = preSong.dateAdded override val dateAdded = preSong.dateAdded

View file

@ -43,6 +43,8 @@ internal data class PreSong(
val format: Format, val format: Format,
val size: Long, val size: Long,
val durationMs: Long, val durationMs: Long,
val bitrateKbps: Int,
val sampleRateHz: Int,
val replayGainAdjustment: ReplayGainAdjustment, val replayGainAdjustment: ReplayGainAdjustment,
val lastModified: Long, val lastModified: Long,
val dateAdded: Long, val dateAdded: Long,

View file

@ -74,6 +74,8 @@ private data object TagInterpreterImpl : TagInterpreter {
disc = song.tags.disc?.let { Disc(it, song.tags.subtitle) }, disc = song.tags.disc?.let { Disc(it, song.tags.subtitle) },
date = song.tags.date, date = song.tags.date,
durationMs = song.tags.durationMs, durationMs = song.tags.durationMs,
bitrateKbps = song.properties.bitrateKbps,
sampleRateHz = song.properties.sampleRateHz,
replayGainAdjustment = replayGainAdjustment =
ReplayGainAdjustment( ReplayGainAdjustment(
song.tags.replayGainTrackAdjustment, song.tags.replayGainTrackAdjustment,