Coder Social home page Coder Social logo

tomoyu719 / simple_sheet_music Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 3.0 2.11 MB

A Flutter package for rendering sheet music on canvas.

Home Page: https://pub.dev/packages/simple_sheet_music

License: MIT License

Kotlin 0.07% Swift 0.97% Objective-C 0.02% Dart 75.38% CMake 10.10% C++ 11.65% C 0.79% HTML 1.01%

simple_sheet_music's People

Contributors

tomoyu719 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

simple_sheet_music's Issues

Bringing together classes whose roles overlap

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:

  1. Combine Classes with Overlapping Responsibilities:

    • Merge MusicObjectStyle, BuiltObject, and ObjectOnCanvas into a unified class or a more cohesive set of classes with distinct responsibilities.
  2. Refactor and Simplify File Structure:

    • Integrate 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.

accidentals are too close to the note

Especially with sharps and naturals, they are rendered too close to the note - see pictures below. Flats and double-flats are a bit better, but still rendered too close compared to standard engraving practices.

Screenshot 2024-07-19 at 10 29 17 PM Screenshot 2024-07-19 at 10 34 11 PM

Avoid primitive types

The int type is used for the position of the Note. To ensure readability and robustness, change to a unique data class, etc.

[feature request] Harmony

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.

Stave doesn't render dead-center

Summary

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.

Example of the issue:

Screenshot 2024-06-23 at 12 34 09 PM

Example code:

@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],
            ),
          ),
        ),
      ),
    );
  }
}

Rendering error when building chords of NoteDuration.whole

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.