-
Notifications
You must be signed in to change notification settings - Fork 2
[REFACTOR] MIDI 이벤트 저장 방식 수정 #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
36cf507
refactor: MIDI 이벤트 저장 구조를 Playing JSONB 방식으로 변경 (#21)
on1yoneprivate af1a11b
refactor: Playing 엔티티의 메트로놈 설정 필드 제거 (#21)
on1yoneprivate 8b3808b
fix: MIDI 데이터 역직렬화 검증 우회 문제 수정 (#21)
on1yoneprivate 119a6df
refactor: 연주 완료 및 MIDI 데이터 검증 로직 개선 (#21)
on1yoneprivate fdddd45
feat: MIDI 저장 및 이벤트 순서 검증 로직 추가 (#21)
on1yoneprivate 9ae4ccd
refactor: duration 필드명을 durationSec으로 변경 (#21)
on1yoneprivate c9ab86f
refactor: MIDI 필터링 후 빈 데이터 검증 추가 (#21)
on1yoneprivate 126ebe5
Merge branch 'develop' into refactor/#21-embed-midi-data
on1yoneprivate af997bd
Merge branch 'develop' into refactor/#21-embed-midi-data
on1yoneprivate 24b79ed
style: 불필요한 와일드카드 import 제거 (#21)
on1yoneprivate 615fc67
refactor: Playing의 User 및 BackingTrack 연관관계 설정 (#21)
on1yoneprivate 5d73598
refactor: Duration을 사용해 시간 변환 로직 개선 (#21)
on1yoneprivate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 0 additions & 104 deletions
104
src/main/java/com/mr/domain/playing/entity/MidiEvent.java
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
src/main/java/com/mr/domain/playing/entity/MidiEventData.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package com.mr.domain.playing.entity; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.mr.domain.playing.entity.enums.MidiType; | ||
| import com.mr.domain.playing.exception.PlayingErrorStatus; | ||
| import com.mr.global.apipayload.exception.GeneralException; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class MidiEventData { | ||
|
|
||
| // 동일 timestamp 내 순서 값 | ||
| @JsonProperty("sequence") | ||
| private final Integer sequence; | ||
|
|
||
| private final MidiType type; | ||
| private final Integer pitch; | ||
| private final Integer velocity; | ||
|
|
||
| @JsonProperty("timestamp_ms") | ||
| private final Long timestampMs; | ||
|
|
||
| private MidiEventData( | ||
| Integer sequence, | ||
| MidiType type, | ||
| Integer pitch, | ||
| Integer velocity, | ||
| Long timestampMs | ||
| ) { | ||
| validateSequence(sequence); | ||
| validateMidiType(type); | ||
| validatePitch(pitch); | ||
| validateVelocity(velocity); | ||
|
Comment on lines
+33
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MidiType을 지금 NOTE_ON, NOTE_OFF만 갖고 있는데 저희 MIDI 데이터를 요 정도만 받아도 되는 건지 궁금해요! (이건 PM님과 논의할 사안인 것 같지만....) 현재는 모든 타입에 pitch와 velocity를 필수로 검증하고 있어, 추후 페달이나 Control Change 이벤트까지 저장한다면 타입별 검증 또는 이벤트 모델 분리가 필요할 것 같아요!! |
||
| validateTimestampMs(timestampMs); | ||
|
|
||
| this.sequence = sequence; | ||
| this.type = type; | ||
| this.pitch = pitch; | ||
| this.velocity = velocity; | ||
| this.timestampMs = timestampMs; | ||
| } | ||
|
|
||
| @JsonCreator | ||
| public static MidiEventData of( | ||
| @JsonProperty("sequence") Integer sequence, | ||
| @JsonProperty("type") MidiType type, | ||
| @JsonProperty("pitch") Integer pitch, | ||
| @JsonProperty("velocity") Integer velocity, | ||
| @JsonProperty("timestamp_ms") Long timestampMs | ||
| ) { | ||
| return new MidiEventData(sequence, type, pitch, velocity, timestampMs); | ||
| } | ||
|
|
||
| private static void validateSequence(Integer sequence) { | ||
| if (sequence == null || sequence < 0) { | ||
| throw new GeneralException(PlayingErrorStatus.INVALID_MIDI_SEQUENCE); | ||
| } | ||
| } | ||
|
|
||
| private static void validateMidiType(MidiType type) { | ||
| if (type == null) { | ||
| throw new GeneralException(PlayingErrorStatus.MISSING_MIDI_TYPE); | ||
| } | ||
| } | ||
|
|
||
| private static void validatePitch(Integer pitch) { | ||
| if (pitch == null || pitch < 0 || pitch > 127) { | ||
| throw new GeneralException(PlayingErrorStatus.INVALID_PITCH_RANGE); | ||
| } | ||
| } | ||
|
|
||
| private static void validateVelocity(Integer velocity) { | ||
| if (velocity == null || velocity < 0 || velocity > 127) { | ||
| throw new GeneralException(PlayingErrorStatus.INVALID_VELOCITY_RANGE); | ||
| } | ||
| } | ||
|
|
||
| private static void validateTimestampMs(Long timestampMs) { | ||
| if (timestampMs == null || timestampMs < 0) { | ||
|
on1yoneprivate marked this conversation as resolved.
|
||
| throw new GeneralException(PlayingErrorStatus.INVALID_TIMESTAMP); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.