-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...s/GameEngineKit/Sources/OldSystem/Exercises/Specialized/ColorMusicPad/ColorMusicPad.swift
This file contains 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,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() | ||
} |
This file contains 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