feat: New getR128Gain function to get track replay gain value#16
Conversation
- These are from know fields from files that I can work with. - I have files that use the `ReplayGain Xing/Info` tag and others with `TXXX`.
- We only return the value assocaited with the track and not the album-wide replay gain.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a getR128Gain API: a Kotlin ReplayGainParser, a native Android MetadataRetrieverModule method to expose the parsed gain, TypeScript TurboModule declaration and JS wrapper, small lyric-handling fixes, and README documentation. ChangesReplay Gain Feature
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@android/src/main/java/com/cyanchill/missingcore/metadataretriever/modules/MetadataRetrieverModule.kt`:
- Around line 309-318: The code can clobber a previously found non-null gain
because the inner break only exits the inner loop; ensure once a non-null gain
is found it is not overwritten by later metadata entries by capturing the parser
result into a candidate and if candidate != null assign to gain and break out of
the outer loop (use a labeled break, e.g., break@outer) or alternatively only
assign when gain is null and candidate is non-null; update the loops around
metadataList and ReplayGainParser(...) accordingly and keep the final
promise.resolve(gain) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 348134cf-3f4c-4ae5-95f6-ef6e159cd4e7
📒 Files selected for processing (5)
README.mdandroid/src/main/java/com/cyanchill/missingcore/metadataretriever/modules/MetadataRetrieverModule.ktandroid/src/main/java/com/cyanchill/missingcore/metadataretriever/utils/ReplayGainParser.ktsrc/NativeMetadataRetriever.tssrc/index.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@android/src/main/java/com/cyanchill/missingcore/metadataretriever/utils/ReplayGainParser.kt`:
- Line 26: The code unsafely indexes frame.values[0] inside the
COMMON_REPLAY_GAIN_TAGS branch which can throw IndexOutOfBoundsException for
empty values; update the logic in ReplayGainParser (the branch that currently
returns frame.values[0].parseReplayGainAdjustment()) to first check
values.isNotEmpty() or use values.firstOrNull()?.parseReplayGainAdjustment() and
handle the null case (return null or a safe default) so empty value lists are
handled without throwing.
- Around line 24-27: handleTextInformationFrame currently assumes
frame.values[0] exists and treats R128 and REPLAYGAIN tags the same; update
handleTextInformationFrame(frame: TextInformationFrame) to first check that
frame.values is not empty (return null if empty) before indexing, and then call
a tag-aware parser: in parseReplayGainAdjustment (or add a helper used by that
function) detect the frame.description (or tag name) equal to R128_TRACK_GAIN
and parse its numeric value as Q7.8 fixed-point by dividing the parsed integer
by 256f, otherwise parse the usual REPLAYGAIN_TRACK_GAIN as a plain float;
ensure you reference the constants R128_TRACK_GAIN and REPLAYGAIN_TRACK_GAIN (or
COMMON_REPLAY_GAIN_TAGS) when choosing the parsing branch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 832b07f2-ad86-416d-9b32-7efe378fde50
📒 Files selected for processing (2)
android/src/main/java/com/cyanchill/missingcore/metadataretriever/modules/MetadataRetrieverModule.ktandroid/src/main/java/com/cyanchill/missingcore/metadataretriever/utils/ReplayGainParser.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- android/src/main/java/com/cyanchill/missingcore/metadataretriever/modules/MetadataRetrieverModule.kt
- Also safely return the 1st value in the array.
|
@coderabbitai review |
✅ Action performedReview finished.
|
This PR introduces a new
getR128Gainfunction that returns the track replay gain value in the embedded metadata. Currently, we support and verified:REPLAYGAIN_TRACK_GAINinTXXXtag for ID3v2.TextInformationFrameclass.ReplayGain Xing/Infotag for ID3v2.Mp3InfoReplayGainclass.Note
We also support
R128_TRACK_GAINinTXXXtag, but have no files to verify.We also support both tags in
VorbisComment, but have no files to verify.Supposedly, the range of values returned should be within
± 20.Examples of Replay Gain in Embedded Metadata
Summary by CodeRabbit
New Features
Bug Fixes
Documentation