Code Monkey home page Code Monkey logo

glnpianoview's Introduction

GLNPianoView

An iOS piano keyboard view for iPhone or iPad, written in Swift 5. Has an IBDesignable preview in interface builder with IBInspectable properties for:

  • Number of keys
  • Hide/show note names on white keys
  • Black key height and width
  • Hightlight keys, with individual colour (optional play note)
  • Custom key labels

Other features

  • Latch/Hold key

All images are drawn using Core Graphics.

Example app

alt tag

Installation

GLNPianoView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'GLNPianoView'

Demo

The Example app demonstrates how to integrate and use GLNPianoView in your project. It includes a simple AVAudioEngine/AVAudioUnitSampler based sound source.

Delegate Methods

func pianoKeyDown(_ keyNumber: Int) {
  // Called when the key corresponding to midi number keyNumber is pressed
}

func pianoKeyUp(_ keyNumber: Int) {
  // Called when the key corresponding to midi number keyNumber is released
}

Key Labels

A key's label must be assigned a value for it to show:

keyboard.setLabel(for: 60, text: "Do")
keyboard.setLabel(for: 62, text: "Re")
keyboard.setLabel(for: 64, text: "Mi")

for noteNumber in 65...72 {
    keyboard.setLabel(for: noteNumber, text: GLNNote.name(for: noteNumber))
}

Requirements

  • Swift 5

Author

Gary Newby

License

Licensed under the MIT License.

glnpianoview's People

Contributors

garynewby avatar gregtour avatar

Watchers

 avatar  avatar

Forkers

gemicn

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.