Giter Site home page Giter Site logo

piano-companion's Introduction

Welcome to the piano companion app!

This innovative piano learning app allows users to upload MIDI files, view them in a library, and stream them to an Arduino that lights up an LED strip to guide you through each note.

See it in action:

app_walkthrough.mp4

How it works:

The first screen the user sees is the Home screen. This screen handles asking for bluetooth permissions and navigating between two screens. Once permissions are granted, the user can go to either the MidiRoomScreen or the MidiUploadScreen.

Upload Screen

The user enters this screen either by selecting "upload" in the home screen or by selecting "select file" in the MidiRoom screen.

The "select file" button opens the Android file picker, narrowed down to just .mid files. From there, it passes the InputStream through convertMidiToSong. This takes all Note On and Note Off events and turns each of them into an array with 3 numbers:
[tick (timestamp), pitch, velocity (volume)]
This, along with user inputted information, is stored in the SongsRepository via insertSong.

Midi Room

The user enters this page either after selecting "finished" in the upload screen or by selecting "Midi Room" in the home screen.

Here, all the songs stored in the local database are displayed in clickable cards. There is a search bar above the list and it narrows down song cards as the user starts typing their query. When the user selects a song, the song ID is sent to ViewMidiScreen via the NavigationDestination.

ViewMidiScreen

A misnomer, this doesn't display a MIDI file but rather holds controls for streaming to the arudino. Currently, an animated countdown displays and then the song is sent via bluetooth. The play/pause buttons, along with rewind/ff, are not operational currently but will send a signal to the arduino.

Navigation

This app uses Compose Navigation. Each screen has an associated NavigationDestination object, which defines the path to the screen and any additional arguments. For navigating to the ViewMidiScreen, a song ID is passed from the MidiRoomScreen via an onClick function created in the AppNavGraph and then used in the ViewMidiViewModel to retrieve the song from the app.

Room

This app uses Room to manage the database. It currently supports searching by song name or artist, getting all the songs, getting one song by name or id, and includes the built-in functions: insert, update, and delete. It is used in the MidiRoomViewModel to insert new songs into the database, and the MidiUploadViewModel to display all saved songs and search through the database.

DI

Hilt is used to inject dependencies, and providers are defined in the AppModule.

BLE

Currently a majority of the code sits in the BLE class, and is hardcoded for a specific device, service, and characteristic (my UUIDs are set in the arduino code). For the purposes of this project, all that needs to be done is connect to the specified device and send a ByteStream and occasionally some other bytes (the behavior of play/pause is TBD). Because of this, the main BLE API is scanAndConnnectToTarget and writeCharacteristic.

piano-companion's People

Contributors

andrea749 avatar

Watchers

Lucian avatar  avatar  avatar

piano-companion's Issues

display Room table

make entries clickable. when selected, send the info via bluetooth to arduino (component in separate repo)

smooth play/pause

when the song starts, there's a flicker from the play to pause button

refactor ble

change BLE so that we only scan and find the device once and after that whenever we send a song it uses the same connection instead of rescanning and reconnecting

refactor ViewMidiViewModel and BLE

refactor vm to inject more classes and ensure that ApplicationContext is being used primarily, and not context tied to the composables.

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.