Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,20 @@
"deviceId": "emulator-5554"
},
{
"name": "iPhone SE (2nd generation) (mobile)",
"name": "iPhone 13 (mobile)",
"request": "launch",
"type": "dart",
"deviceId": "B74B1F44-56AD-4D14-B1FD-6F685C8BB7C2"
},
{
"name": "iPhone 12 (mobile)",
"request": "launch",
"type": "dart",
"deviceId": "7182391C-3F76-4577-9A48-CDDD0EE66DFB"
},
{
"name": "iPad Pro (12.9-inch) (2nd generation) (mobile)",
"request": "launch",
"type": "dart",
"deviceId": "086D2D71-E736-4291-A91F-C575C0B5C060"
},
{
"name": "iPad Pro (12.9-inch) (4th generation) (mobile)",
"request": "launch",
"type": "dart",
"deviceId": "47D83A08-59A9-4E80-A6FD-7805D9F9BA52"
"deviceId": "77171629-E070-4F03-9FD7-0898D08E2DEA"
},
],
"compounds": [
{
"name": "iOS Screenshot Devices",
"configurations": [
"iPad Pro (12.9-inch) (4th generation) (mobile)",
"iPhone SE (2nd generation) (mobile)",
"iPhone 12 (mobile)",
"iPad Pro (12.9-inch) (2nd generation) (mobile)"
// "iPad Pro (12.9-inch) (4th generation) (mobile)",
// "iPhone SE (2nd generation) (mobile)",
// "iPhone 12 (mobile)",
// "iPad Pro (12.9-inch) (2nd generation) (mobile)"
],
}
]
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 29
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -48,7 +48,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.beatscratch.beatscratch_flutter_redux"
minSdkVersion 25
targetSdkVersion 30
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ fun Music.Instrument.sendSelectInstrument() {

byte3[0] = (MidiConstants.CONTROL_CHANGE or channel)
byte3[1] = MidiConstants.CONTROL_VOLUME
byte3[2] = (volume * 127).toByte()
byte3[2] = (volume * 127).toInt().toByte()
sendToStream(byte3)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data class NoteOnEvent(
): MidiEvent {
override val eventByteCount get() = 3
override fun withChannelOverride(newChannel: Byte) = NoteOnEvent(midiNote, velocity, newChannel)
override fun withVelocityMultiplier(velocityMultiplier: Float) = NoteOnEvent(midiNote, (velocity * velocityMultiplier).toByte(), channel)
override fun withVelocityMultiplier(velocityMultiplier: Float) = NoteOnEvent(midiNote, (velocity * velocityMultiplier).toInt().toByte(), channel)
override fun send(immediately: Boolean, record: Boolean) {
AndroidMidi.playNote(midiNote, velocity, channel, immediately, record)
}
Expand All @@ -29,7 +29,7 @@ data class NoteOffEvent(
): MidiEvent {
override val eventByteCount get() = 3
override fun withChannelOverride(newChannel: Byte) = NoteOffEvent(midiNote, velocity, newChannel)
override fun withVelocityMultiplier(velocityMultiplier: Float) = NoteOffEvent(midiNote, (velocity * velocityMultiplier).toByte(), channel)
override fun withVelocityMultiplier(velocityMultiplier: Float) = NoteOffEvent(midiNote, (velocity * velocityMultiplier).toInt().toByte(), channel)
override fun send(immediately: Boolean, record: Boolean) {
AndroidMidi.stopNote(midiNote, channel, immediately, record)
}
Expand Down
5 changes: 3 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
buildscript {
ext.kotlin_version = '1.3.71'
ext.android_gradle_tools_version = '7.1.2'
ext.kotlin_version = '1.6.10'
ext.protobufVersion = '0.8.11'
ext.kotlinx_io_version = '0.1.16'

Expand All @@ -9,7 +10,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "com.android.tools.build:gradle:$android_gradle_tools_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.protobuf:protobuf-gradle-plugin:$protobufVersion"
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
2 changes: 1 addition & 1 deletion build-release-ios
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ echo "# Building, Archiving, and Uploading for iOS" && \
echo "#-----------------------------------------------------------------------" && \
flutter build ios | sed 's/.*/\[iOS\] &/' && \
echo "Archiving iOS app..." && \
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -configuration release archive | sed 's/.*/\[iOS\] &/' && \
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -configuration release archive | sed 's/.*/\[iOS: Archive\] &/' && \
echo "iOS app built! Uploading to the App Store..." && \
./build-upload-ios | sed 's/.*/\[iOS: App Store Upload\] &/'
17 changes: 11 additions & 6 deletions build-release-macos
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ echo "# Building for macOS and archiving app" && \
echo "#-----------------------------------------------------------------------" && \
flutter build macos | sed 's/.*/\[macOS\] &/' && \
cd build/macos/Build/Products/Release && \
tar -cavf BeatFlutter.tar.bz2 BeatScratch.app && open . && cd - && \
echo "Signing macOS app with certificate EC73E3C309C841E94640BBA80B3FE67508A10A95" && \
codesign --deep --force --verbose --sign "EC73E3C309C841E94640BBA80B3FE67508A10A95" BeatScratch.app | sed 's/.*/\[macOS: Codesign\] &/' && \
echo "BZ2-compressing macOS app" && \
tar -cavf BeatFlutter.tar.bz2 BeatScratch.app | sed 's/.*/\[macOS: BZ2-Compress\] &/' && \
open . && cd - && \
echo "macOS app standalone built! Manually upload to Dropbox" && \
open "https://www.dropbox.com/home" && \
echo "Archiving macOS app..." && \
xcodebuild -workspace macos/Runner.xcworkspace -scheme Runner -configuration release archive | sed 's/.*/\[iOS\] &/' && \
echo "macOS app archive built! Uploading to the App Store..." && \
./build-upload-macos | sed 's/.*/\[macOS: App Store Upload\] &/'
open "https://www.dropbox.com/home"
# && \
# echo "Archiving macOS app..." && \
# xcodebuild -workspace macos/Runner.xcworkspace -scheme Runner -configuration release archive | sed 's/.*/\[macOS: Archive\] &/' && \
# echo "macOS app archive built! Uploading to the App Store..." && \
# ./build-upload-macos | sed 's/.*/\[macOS: App Store Upload\] &/'
14 changes: 7 additions & 7 deletions build-release-web
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
cd "$(dirname "$0")"

echo "#-----------------------------------------------------------------------" && \
echo "# Building for Web and copying to ../beatscratch-page/app-staging[-skia]" && \
echo "# Building for Web and copying to ../beatscratch-page/app-staging" && \
echo "#-----------------------------------------------------------------------" && \
flutter build web --dart-define=FLUTTER_WEB_USE_SKIA=false --release | sed 's/.*/\[Web\] &/' && \
flutter build web --web-renderer canvaskit --release | sed 's/.*/\[Web\] &/' && \
echo "Copying build..." && \
cp -r build/web/* ../beatscratch-page/app-staging && \
echo "Web app built to app-staging with FLUTTER_WEB_USE_SKIA=false! Manually copy to prod app and/or deploy to beatscratch.io" && \
flutter build web --dart-define=FLUTTER_WEB_USE_SKIA=true --release | sed 's/.*/\[Web\] &/' && \
echo "Copying build..." && \
cp -r build/web/* ../beatscratch-page/app-staging-skia && \
echo "Web app built to app-staging with FLUTTER_WEB_USE_SKIA=true! Manually copy to prod app and/or deploy to beatscratch.io"
echo "Web app built to app-staging! Manually copy to prod app and/or deploy to beatscratch.io"
# flutter build web --dart-define=FLUTTER_WEB_USE_SKIA=true --release | sed 's/.*/\[Web\] &/' && \
# echo "Copying build..." && \
# cp -r build/web/* ../beatscratch-page/app-staging-skia && \
# echo "Web app built to app-staging with FLUTTER_WEB_USE_SKIA=true! Manually copy to prod app and/or deploy to beatscratch.io"

32 changes: 16 additions & 16 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ PODS:
- Flutter
- package_info_plus (0.4.5):
- Flutter
- path_provider (0.0.1):
- path_provider_ios (0.0.1):
- Flutter
- sensors (0.0.1):
- Flutter
- share (0.0.1):
- Flutter
- shared_preferences (0.0.1):
- shared_preferences_ios (0.0.1):
- Flutter
- SwiftProtobuf (1.13.0)
- url_launcher (0.0.1):
- url_launcher_ios (0.0.1):
- Flutter
- webview_flutter_wkwebview (0.0.1):
- Flutter
Expand All @@ -34,12 +34,12 @@ DEPENDENCIES:
- flutter_midi_command (from `.symlinks/plugins/flutter_midi_command/ios`)
- native_device_orientation (from `.symlinks/plugins/native_device_orientation/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- sensors (from `.symlinks/plugins/sensors/ios`)
- share (from `.symlinks/plugins/share/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
- SwiftProtobuf
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)

SPEC REPOS:
Expand All @@ -61,16 +61,16 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/native_device_orientation/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider:
:path: ".symlinks/plugins/path_provider/ios"
path_provider_ios:
:path: ".symlinks/plugins/path_provider_ios/ios"
sensors:
:path: ".symlinks/plugins/sensors/ios"
share:
:path: ".symlinks/plugins/share/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"
shared_preferences_ios:
:path: ".symlinks/plugins/shared_preferences_ios/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"

Expand All @@ -82,13 +82,13 @@ SPEC CHECKSUMS:
flutter_midi_command: 4acc18c6391c574d21f1d3a1cc40c7fe06ff461f
native_device_orientation: 3b4cfc9565a7b879cc4fde282b3e27745e852d0d
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
path_provider: d1e9807085df1f9cc9318206cd649dc0b76be3de
path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5
sensors: 84eb7a30e47a649e4172b71d6e81be614c280336
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
shared_preferences: 5033afbb22d372e15aff8ff766df9021b845f273
shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
SwiftProtobuf: fd4693388a96c8c2df35d3b063272b0e7c499d00
url_launcher: b6e016d912f04be9f5bf6e8e82dc599b7ba59649
webview_flutter_wkwebview: 44aa025fbcf6730d808f1e0d86a5af5ac25fa8de
url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
webview_flutter_wkwebview: 005fbd90c888a42c5690919a1527ecc6649e1162

PODFILE CHECKSUM: 79aecb95524f6b2d9ca54f898d51b01d778cce9b

Expand Down
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1250;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
5 changes: 5 additions & 0 deletions lib/beatscratch_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class BeatScratchPlugin {
static bool _playbackForceDisabled = false;
static bool get supportsPlayback =>
_supportsPlayback && !_playbackForceDisabled;
static bool _countInInitiated = false;
static bool get countInInitiated => _countInInitiated;

static MethodChannel _channel = MethodChannel('BeatScratchPlugin')
..setMethodCallHandler((call) {
Expand All @@ -48,6 +50,7 @@ class BeatScratchPlugin {
break;
case "notifyPlayingBeat":
_notifyPlayingBeat(call.arguments);
_countInInitiated = false;
return Future.value(null);
break;
case "notifyPaused":
Expand All @@ -57,6 +60,7 @@ class BeatScratchPlugin {
break;
case "notifyCountInInitiated":
_playing = false;
_countInInitiated = true;
onCountInInitiated?.call();
return Future.value(null);
break;
Expand Down Expand Up @@ -440,6 +444,7 @@ class BeatScratchPlugin {
/// Starts the playback thread
static void play() {
_playing = true;
_countInInitiated = false;
_play();
}

Expand Down
3 changes: 0 additions & 3 deletions lib/drawing/canvas_tone_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class CanvasToneDrawer {
double get halfStepWidth => axisLength / halfStepsOnScreen;
double get diatonicStepWidth => halfStepWidth * 12 / 7;

// dip(value: double): Int
//fun dip(value: Int): Int
bool showSteps;
Chord chord = Chord()
..rootNote = NoteName()
..chroma = 2047;
Expand Down
34 changes: 20 additions & 14 deletions lib/drawing/music/colorblock_music_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import '../../util/music_theory.dart';
class ColorblockMusicRenderer extends BaseMusicRenderer {
double uiScale = 1;
@override
bool showSteps = true;
@override
double get halfStepsOnScreen => (highestPitch - lowestPitch + 1).toDouble();
double colorblockAlpha;
static double stepLineScaleThreshold = 0.7;

draw(Canvas canvas) {
alphaDrawerPaint.strokeWidth = 0;
bounds = overallBounds;
canvas.save();
canvas.translate(0, bounds.top);
if (uiScale > 0.7) {
if (uiScale > stepLineScaleThreshold) {
_renderSteps(canvas);
}
double alphaMultiplier = (isMelodyReferenceEnabled) ? 1.0 : 2.0 / 3;
Expand All @@ -36,18 +35,16 @@ class ColorblockMusicRenderer extends BaseMusicRenderer {
_renderSteps(Canvas canvas) {
alphaDrawerPaint.color =
Colors.black87.withAlpha((colorblockAlpha * 255 * 0.8).toInt());
if (showSteps) {
var linePosition = startPoint; // - 12 * halfStepWidth;
while (linePosition < axisLength) {
if (renderVertically) {
canvas.drawLine(Offset(bounds.left, linePosition),
Offset(bounds.right, linePosition), alphaDrawerPaint);
} else {
canvas.drawLine(Offset(linePosition, bounds.top),
Offset(linePosition, bounds.bottom), alphaDrawerPaint);
}
linePosition += halfStepWidth;
var linePosition = startPoint; // - 12 * halfStepWidth;
while (linePosition < axisLength) {
if (renderVertically) {
canvas.drawLine(Offset(bounds.left, linePosition),
Offset(bounds.right, linePosition), alphaDrawerPaint);
} else {
canvas.drawLine(Offset(linePosition, bounds.top),
Offset(linePosition, bounds.bottom), alphaDrawerPaint);
}
linePosition += halfStepWidth;
}
}

Expand Down Expand Up @@ -97,13 +94,22 @@ class ColorblockMusicRenderer extends BaseMusicRenderer {
bounds.height - bounds.height * (realTone - lowestPitch) / 88;
double bottom =
bounds.height - bounds.height * (realTone - lowestPitch + 1) / 88;
if (uiScale < stepLineScaleThreshold) {
double height = top - bottom;
double extraHeight =
1.5 * height * (stepLineScaleThreshold - uiScale);
print("extraHeight=$extraHeight");
top += extraHeight;
bottom -= extraHeight;
}
canvas.drawRect(
Rect.fromLTRB(bounds.left + leftMargin, top,
bounds.right - rightMargin, bottom),
alphaDrawerPaint);
});
}

// Render note offs
if (uiScale > highResUiScale) {
tones = melody.noteOffsAt(elementPosition % melody.length).toList();

Expand Down
Loading