tomoyu719 / simple_sheet_music Goto Github PK
View Code? Open in Web Editor NEWA Flutter package for rendering sheet music on canvas.
Home Page: https://pub.dev/packages/simple_sheet_music
License: MIT License
A Flutter package for rendering sheet music on canvas.
Home Page: https://pub.dev/packages/simple_sheet_music
License: MIT License
To improve the readability and maintainability of the project, consider consolidating classes and files that serve overlapping roles. Currently, the project has several classes and files that cover similar functionalities, such as MusicObjectStyle
, BuiltObject
, and ObjectOnCanvas
. Similarly, files like sheet_music_builder.dart
, sheet_music_gesture_handler.dart
, sheet_music_layout.dart
, and sheet_music_renderer.dart
also have overlapping responsibilities. By integrating these, you can streamline the codebase and enhance its clarity.
Consider the following steps for integration:
Combine Classes with Overlapping Responsibilities:
MusicObjectStyle
, BuiltObject
, and ObjectOnCanvas
into a unified class or a more cohesive set of classes with distinct responsibilities.Refactor and Simplify File Structure:
sheet_music_builder.dart
, sheet_music_gesture_handler.dart
, sheet_music_layout.dart
, and sheet_music_renderer.dart
into a more consolidated structure, possibly breaking them down into modules that are easier to navigate and understand.This approach will help improve both the readability and maintainability of the codebase, making it easier for current and future developers to work with the project.
The int type is used for the position of the Note. To ensure readability and robustness, change to a unique data class, etc.
Nice declarative solution to the tricky problem of programmatic music engraving! I think it would be valuable to add the ability to render chords. If you have an idea on how this could be done, feel free to share and I could try and attempt to help if needed on a forked version of the repo.
While the widget is behaving as expected (the bottom staff line renders at (0, 0) in the coordinate system), this causes issues when centering the widget within a container. Rendering dead-center would be useful for displaying figures for music theory education.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Simple Sheet Music Example')),
body: Center(
child: Container(
decoration: BoxDecoration(border: Border.all()),
width: 200.0,
height: 200.0,
child: Align(
alignment: Alignment.center,
child: SimpleSheetMusic(
initialClef: initialClef,
height: 100,
width: 100,
staffs: [staff],
),
),
),
),
);
}
}
Hi, thanks for implementing chords!
I ran across the following error preventing the rendering of whole note chords - you should be able to reproduce the issue by trying to create a ChordNote with noteDuration
set to NoteDuration.whole
.
Exception caught:
════════ Exception caught by rendering library ═════════════════════════════════
The following NoSuchMethodError was thrown during paint():
The method '[]' was called on null.
Receiver: null
Tried calling: []("stemUpSE")
Truncated stack trace:
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
object_patch.dart:38
#1 GlyphMetadata.stemRootOffset (package:simple_sheet_music/src/glyph_metadata.dart:56:27)
glyph_metadata.dart:56
#2 ChordNoteMetrics._noteStemRootOffset (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:279:16)
chord_note.dart:279
#3 ChordNoteMetrics._uppestNoteStemRootOffset (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:242:43)
chord_note.dart:242
#4 ChordNoteMetrics._tipNoteStemRootToStaffCenterDist (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:251:9)
chord_note.dart:251
#5 ChordNoteMetrics._isStemCentered (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:256:7)
chord_note.dart:256
#6 ChordNoteMetrics.stemTipOffset (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:292:9)
chord_note.dart:292
#7 ChordNoteMetrics._top (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:182:9)
chord_note.dart:182
#8 ChordNoteMetrics._bbox (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:174:42)
chord_note.dart:174
#9 ChordNoteMetrics.width (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:209:46)
chord_note.dart:209
#10 MeasureMetrics.objectsWidth.<anonymous closure> (package:simple_sheet_music/src/measure/measure_metrics.dart:37:54)
measure_metrics.dart:37
...
...
...
The following RenderObject was being processed when the exception was fired: RenderCustomPaint#e2ba3 relayoutBoundary=up4
parentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=175.0, 0.0<=h<=137.5)
size: Size(175.0, 87.5)
painter: SheetMusicRenderer#7c9ca()
preferredSize: Size(175.0, 87.5)
RenderObject: RenderCustomPaint#e2ba3 relayoutBoundary=up4
parentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=175.0, 0.0<=h<=137.5)
size: Size(175.0, 87.5)
painter: SheetMusicRenderer#7c9ca()
preferredSize: Size(175.0, 87.5)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.