Facebook Twitter Instagram
    DeepCrazyWorld
    Facebook Twitter Instagram Pinterest YouTube
    • FLUTTER
      • FLUTTER APP
        • QRCode
        • Quiz App
        • Chat GPT
        • PDF App
        • News App
        • Fitness App
        • Weather App
        • BMI Calculator
        • GAME APP
        • Ecommerce App
        • wallpaper App
        • Finance app
        • Chat App
        • Wallet App
        • Taxi App
        • Quran app
        • Music player app
      • FLUTTER UI
        • Splash Screen
        • Onboarding Screen
        • Login Screen
        • Card Design
        • Drawer
    • PROJECT
      • Android Projects
      • College Projects
      • FLUTTER APP
      • Project Ideas
      • PHP Projects
      • Python Projects
    • SOURCE CODE
    • ANDROID
      • ANDROID APP
      • GAME APP
      • ANDROID STUDIO
    • MCQ
      • AKTU MCQ
        • RPA MCQ
        • COA MCQ
        • HPC MCQ
        • SPM MCQ
        • Renewable Energy All MCQ
        • Data Compression MCQ
        • Data Structure MCQ
        • Digital Image Processing MCQ
        • Software Engineering MCQ
        • Machine Learning MCQ
        • Artificial Intelligence MCQ
      • D PHARMA MCQ
        • Pharmaceutics – I MCQ
        • Pharmacognosy MCQ
        • Pharmaceutical Chemistry MCQ
        • Biochemistry and Clinical Pathology MCQ
        • Human Anatomy and Physiology MCQ
        • Heath Education and Community Pharmacy MCQ
    • INTERVIEW QUESTIONS
      • Flutter Interview Questions
      • INTERVIEW QUESTIONS
      • Python Interview Questions
      • Coding ninjas solution
    • MORE
      • WORDPRESS
        • SEO
        • TOP 10 WORDPRESS THEME
      • PRODUCTIVITY
      • Program
      • QUOTES
    DeepCrazyWorld
    Home»ANDROID APP»How to make Best Piano App in Android Studio with source code
    ANDROID APP

    How to make Best Piano App in Android Studio with source code

    DeepikaBy DeepikaAugust 18, 2020Updated:January 19, 2022No Comments5 Mins Read

    Creating a Virtual Piano Application for Android
    Best Piano Apps for Android .Perfect piano app is an 99-key piano simulation mobile application that represents a real-life piano. It has a bunch of very clever features that makes it a wonderful tool to practice your piano and keyboard skills in make piano app in android studio.

    Some of these features are single and double row mode, dual players mode (you can play with multiple people), chord mode (a mode that highlights the chords and tells you which ones work together), multi touch screen support (very important for a mobile application like this as it lets you touch the screen at multiple places at the same time) and an option to change the key widths.

    Perfect pianos also has a learn to play mode, that will teach you step by step how to play thousands of popular songs with different speed and difficulty adjustments. What makes this mobile application, even more impressive is that it has midi keyboard USB support, which means you can connect a midi keyboard to your phone and play the midi controller through sounds on the application.

    <img decoding=

    Table of Contents

    Toggle
    • Creating a Virtual Piano App for Android
    • Make Piano App in Android studio
    • Piano App in Android studio
    • YouTube Video
    • Creating Piano app in android studio
    • Download Source Code
      • Piano App APK Download : Click Me
    • Conclusion
      • Cheers!
    • READ MORE

    Creating a Virtual Piano App for Android

    What makes this mobile application even greater is that you can record the piano and play it back. This simple application is really all you need in a piano simulation device. It will help you improve, practice and learn songs.


    Now, we can create our dedicated PianoView. It will override the View from the Android standard SDK. We will render 14 white keys and 10 black keys for our Piano. We will use two lists to store the white and black keys of the Piano. Finally, we define a property for the AudioSoundPlayer object we will use to play the sounds associated to each key.
    It will give us the following declaration for the class :

    Make Piano App in Android studio


    In the onSizeChanged callback of our PianoView object, we calculate the key’s width and we get the height for the keys. With these values, we can create the Key’s objects for the white and the black keys. For each key, we associate a RectF instance which will be used to represent them on the screen :


    In the onDraw method of our PianoView, we have just to iterate on the key’s list to draw their RectF instance associated on the screen. For a white key, we use the white painter if the key is not down and the yellow painter otherwise. For a black key, we use the black painter if the key is not down and the yellow painter otherwise. And we don’t forget to draw the lines separating the white keys :


    Like our Piano will support multi touches, we need to iterate on the point touched by the user. To know the number of points touched, we call the method of the current event. Then, we get the coordinates of each point and we try to get the key associated by calling method we will define later. If a key is well associated to the touched point, we set its down property to true.
    After that, we iterate on all the keys of our Piano. If a key is down and its sound associated is not playing, we play the sound by calling the play Note method of the instance. Then, we redraw the Piano View by calling its invalidate method. Otherwise we release the current key by calling the release Key method.

    Piano App in Android studio


    If the key is not down, we call the stopNote method of the AudioSoundPlayer instance and we release the key :
    Finally, we define the keyForCoords and releaseKey methods. In the first method, we iterate on the keys of the Piano to find if a key is associated to the tuple of coordinates passed in parameter. In the second method, we use a Handler object and we pass a Runnable implementation in its postDelayed method to release a specific Key in 100 ms. After that, we don’t forget to redraw the view to see the updates on the screen :

    YouTube Video


    Just below, you can discover the complete source code for the Piano View :
    Playing the music of our Piano
    To play the music of our Piano, we need to create the Audiovisuals object seen previously in this tutorial. Each sound will be played in a dedicated thread. So, we need a property to store the Play Thread objects. Besides, we will use a Sparse Array to associate each index of the keys with a sound name. Finally, we define two constants for the volumes of the sounds we will play :
    The sounds’ files will be stored in the assets folder of our Android project.

    Creating Piano app in android studio

    Defining the User Interface of our Piano Application
    The components of our Piano Application written, we can define the User Interface of our Piano. It will be quite simple : just a PianoView matching the parent layout :


    Writing the Java code of the Piano Activity
    Finally, we can just have a look to the Java code of the PianoActivity. Nothing to write, all is already good :


    Our Virtual Piano in Action
    Now, it is the best part of our tutorial since we are going to put our Virtual Piano in action. If you followed the tutorial correctly, you should have the following result on your smartphone or tablet :

    Download Source Code

    Click below to get the full source code android Piano application.

    Piano App APK Download : Click Me

    <img loading=

    Conclusion

    We have successfully created a Piano App Android application using Android Studio.


    Cheers!


    Don’t Forget to Share this Post.

    Don’t hesitate to give me your feedback for this tutorial in comments.
    You can also visit Technic Dude Channel on YouTube to discover more tutorials on Android Development :

    How to Create Story App in Android Studio Step by Step

    READ MORE

    Share. Facebook Twitter LinkedIn WhatsApp Telegram Pinterest Reddit Email
    Previous ArticleHow to Create Story App in Android Studio Step by Step
    Next Article How to Create Quiz in Blogger Quiz With Start Button | Responsive Quiz

    Related Posts

    Music player app in flutter and dart using node.js music API

    ANDROID APP 2 Mins Read

    How to create Simple movie app with Source code 2023

    ANDROID APP 4 Mins Read

    Scratch to Win Android Earning App (Admob, FB Ads, StartApp, Unity Ads)

    ANDROID APP 2 Mins Read

    Covid-19 Tracker App(Coronavirus Tracker) source code 2023

    ANDROID APP 3 Mins Read

    Comments are closed.

    Recent Posts
    • Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile March 29, 2025
    • Creating an Instruction UI Screen in Flutter Application March 29, 2025
    • Animated Backgrounds in Flutter: A Complete Guide March 15, 2025
    • How to make Diary App using flutter stepwise using getx August 31, 2024
    • How to Create Music Player UI screen with fully functional in flutter August 30, 2024
    • How to make ListView Builder Ui in flutter with Source Code August 29, 2024
    • Create a TabBar View in flutter with fully functional stepwise August 28, 2024
    • How to create TabBar view in flutter with source code step wise August 27, 2024
    • How to make Heart rate measure app with Flutter stepwise August 26, 2024
    • How to make ChatGpt App in flutter with source code Stepwise August 25, 2024
    Facebook Twitter Instagram Pinterest YouTube
    • About
    • Contact
    • Disclaimer
    • Privacy Policy
    Copyright by DeepCrazyWorld © 2025

    Type above and press Enter to search. Press Esc to cancel.