Skip to content

Commit

Permalink
🔀️ Merge branch 'hugo/feature/Add-MusicColorPad' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Dec 6, 2024
2 parents 3773839 + 313b551 commit 1e6e276
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Leka - iOS Monorepo
# Copyright APF France handicap
# SPDX-License-Identifier: Apache-2.0

version: 1.0.0
uuid: 8439D1EE7DD846ACB048145089F34C33
name: color_music_pad

created_at: "2024-12-06T11:17:39.636246"
last_edited_at: "2024-12-06T11:17:39.636246"
status: published

authors:
- leka

skills:
- relationship_tablet_robot
- sensory_integration/vision
- sensory_integration/hearing
- sensory_integration

tags:
- colors
- music
- standalone_activity
- robot_colors
- sensory_stimulation

hmi:
- tablet_robot

types:
- one_on_one

locales:
- en_US
- fr_FR

l10n:
- locale: fr_FR
details:
icon: color_music_pad

title: Pavé musical coloré
subtitle: null

short_description: |
Jouer de la musique avec Leka sur des larges touches colorées.
description: |
Lorem Ipsum
instructions: |
Lorem Ipsum
- locale: en_US
details:
icon: color_music_pad

title: Color Music Pad
subtitle: null

short_description: |
Play music with Leka on large colored keys.
description: |
Lorem Ipsum
instructions: |
Lorem Ipsum
exercises_payload:
options:
shuffle_exercises: false
shuffle_groups: false

exercise_groups:
- group:
- interface: colorMusicPad
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ content:
- melody-CB995F829411449AB32E6B8A688E3DDB
- xylophone_pentatonic-7C1DDED6C6D44913B9A7D4EB4AEE8F6B
- xylophone_heptatonic-65193102AE2947439ABB82D5891EDDBA
- color_music_pad-8439D1EE7DD846ACB048145089F34C33
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ public extension Exercise {
case melody
case pairing
case memory
case colorMusicPad
}
}
1 change: 1 addition & 0 deletions Modules/ContentKit/Sources/Exercise/Exercise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public struct Exercise: Decodable {
(.gamepadColorPad, .none),
(.gamepadArrowPad, .none),
(.hideAndSeek, .none),
(.colorMusicPad, .none),
(.pairing, .none):
self.payload = nil

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Leka - iOS Monorepo
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import AudioKit
import DesignKit
import RobotKit
import SwiftUI

struct ColorMusicPad: View {
// MARK: Internal

@StateObject var midiPlayer: MIDIPlayer = .init(instrument: MIDIInstrument.xylophone)

var body: some View {
LazyVGrid(columns: self.columns, spacing: self.kHorizontalSpacing) {
ForEach(0..<10) { index in
Rectangle()
.fill(self.colors[index].screen)
.onTapGesture {
Robot.shared.shine(.all(in: self.colors[index]))
self.midiPlayer.noteOn(number: self.scale.notes[index])
}
.frame(width: self.kTileWidth, height: self.kTileHeight)
}
}
}

// MARK: Private

private let scale: MIDIScale = .majorPentatonicDoubleOctave
private let colors: [Robot.Color] = [.lightPink, .red, .orange, .yellow, .green, .mint, .lightBlue, .blue, .purple, .pink]
private let columns = Array(repeating: GridItem(), count: 5)
private let kHorizontalSpacing: CGFloat = 0
private let kTileWidth: CGFloat = 220
private let kTileHeight: CGFloat = 600
}

#Preview {
ColorMusicPad()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import AudioKit
enum MIDIScale: String {
case majorPentatonic
case majorHeptatonic
case majorPentatonicDoubleOctave

// MARK: Internal

Expand All @@ -16,6 +17,8 @@ enum MIDIScale: String {
[24, 26, 28, 31, 33]
case .majorHeptatonic:
[24, 26, 28, 29, 31, 33, 35, 36]
case .majorPentatonicDoubleOctave:
[24, 26, 28, 31, 33, 36, 38, 40, 43, 45]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ public struct ActivityView: View {
exercise: self.viewModel.currentExercise,
data: self.viewModel.currentExerciseSharedData
)

case .colorMusicPad:
ColorMusicPad()
}
}

Expand Down
9 changes: 9 additions & 0 deletions Modules/RobotKit/Sources/Robot+Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public extension Robot {
case purple
case pink
case yellow
case mint
case lightPink

// MARK: Public

Expand All @@ -96,6 +98,10 @@ public extension Robot {
.pink
case .yellow:
.yellow
case .mint:
.mint
case .lightPink:
.lightPink
}
}
}
Expand All @@ -118,6 +124,9 @@ public extension Robot.Color {
static let purple: Robot.Color = .init(robot: 20, 0, 80, screen: 173, 73, 247)
static let pink: Robot.Color = .init(robot: 255, 0, 127, screen: 252, 103, 178)
static let yellow: Robot.Color = .init(robot: 255, 255, 0, screen: 251, 232, 0)

static let mint: Robot.Color = .init(robot: 0, 255, 150, screen: 173, 235, 179)
static let lightPink: Robot.Color = .init(robot: 255, 0, 255, screen: 218, 177, 218)
}

// swiftlint:enable nesting identifier_name line_length
6 changes: 5 additions & 1 deletion Specs/jtd/activity.jtd.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@
"ref": "$exercise/payload/memory"
}
}
},
"colorMusicPad": {
"properties": {}
}
}
},
Expand Down Expand Up @@ -464,7 +467,8 @@
"musicalInstruments",
"melody",
"pairing",
"memory"
"memory",
"colorMusicPad"
]
},
"$exercise/gameplay": {
Expand Down

0 comments on commit 1e6e276

Please sign in to comment.