SkillAgentSearch skills...

ROMPlayer

AudioKit Sample Player (ROM Player) - EXS24, Sound Font, Wave Player

Install / Use

/learn @AudioKit/ROMPlayer

README

AudioKit ROM / Sample Player

Build Status License Twitter Follow

AK ROM Player

Welcome to the official AudioKit example of a sample-based music instrument written in Swift. It can be modified to play EXS24, Wave, or Sound Fonts. This code is lightweight and demonstrates how you can make a beautiful sounding, pro-level instrument with small amount of code.

If you're new to AudioKit, you can learn more and view getting started links: here.

App Store Example

Video introduction for this app and project:
https://vimeo.com/244897673

The AudioKit FM Player is built with this code:
Download in App Store here.

New AKSampler Version

This updated code is powered by the new, superior AKSampler code written by Shane Dunne. Special thanks to Shane Dunne for his great work in making this happen. There is a legacy branch for the previous code based on Apple's sample-playback code. The legacy code plays EXS files. While this new code plays SFZ files.

Shane has also documented tips for preparing samples to use with the new AKSampler.

Code Features

  • Beautiful sound engine
  • MIDI input for notes, pitch bend, mod wheel, after touch
  • On screen "Piano" keyboard that can be customized
  • Reverb, Delay, Bitcrush, AutoPan, Stereo Fatten
  • Lowpass Filter and LFO
  • MIDI Learn knobs
  • Features the new cross-platform AKSampler engine
  • Example code written entirely in Swift 4 & AudioKit 4
  • Attack and Release Knobs

Getting Started

I have tried to streamline this code. There is a focus on the core-functionality to make it easy-to-understand. That being said, audio programming can be challenging. This may be difficult for complete beginners. And, new frameworks can be overwhelming, even for experienced developers.

CocoaPods
This repo uses CocoaPods to easily add AudioKit to your project.

Using the Terminal app in your mac, change directories to the folder that contains this project. The correct directory contains a file called podfile

Run pod install from the command line. This will add AudioKit & AudioKit UI to project

Then open RomPlayer.xcworkspace in Xcode

Requirements

  • Mac or computer running Xcode 9 (Free Download)
  • Some knowledge of programming, specifically Swift & the iOS SDK

If you are new to iOS development, I highly recommend the Ray Wenderlich videos. There is also a great tutorial on basic synthesis with AudioKit here.

Included Sounds

AK Sample Player

In this repo, I've included four preset sounds I sampled from my TX81z hardware FM synthesizer using the sampling software SampleRobot. The LoTine81z sound includes 3 velocity layers. The other sounds include a few samples to demonstrate the sounds while keeping the repo size tight.

You are free to use the instruments included in this repo as you see fit- In a game, music app, or just for whatever. It would be cool if you didn't resell them.

AKSampler reads .wv files compressed using the open-source Wavpack software. On the Mac, you must first install the Wavpack command-line tools. Then you can use the following Python 2 script to compress a whole folder-full of .wav files. See this excellent documentation by Shane Dunne for more info on preparing samples.

Using Samples

You can replace the included example sample instruments with your own instruments.

add samples

  1. Add your SFZ files and samples to the /Sounds/sfz/ directory
  2. Type in the name of the instruments in the ParentViewController.swift file

Other Sampler File Formats
You can use a tool you already know (such as Kontakt) to create and arrange the sample instrument key mapping and velocity layers. Then, you can easily convert Kontakt instruments to SFZ with tools such as this. Then, remake the effects using AudioKit. That way, you'll have dynamic sounds and complete control over the effects.

This example code loads SFZ intruments. It is recommended that you convert your file formats to SFZ. If you have to use EXS or SF2, there are other types of sample playback routines in AudioKit you can use instead.

Sound Manipulation

There are all kinds of filters, effects, and other audio manipulation classes included with AudioKit to get you started. You can browse the documentation here.

And, explore over 100+ playgrounds, created by the lovely & talented Aure Prochazka. These byte size code playgrounds allow you to easily experiment with sound & code.

You may also want to explore AU Lab, a free tool from Apple. It is available from the "more" section of the Apple Developer portal. As of this text, the current version is in the Additional Tools for Xcode 9 package.

Additionally, these docs and tips will also prove valuable if you want to dive in at a deeper level than the AKSampler.

Making Graphics

IMPORTANT: You need to change the graphics to upload an app to the app store. Apple does not allow apps to use stock template graphics. Plus, you want your app to be part of the expression of your artistic vision.

For example, if you were releasing a new music album, you would not want to use someone else's album artwork. You would want your own!

Think of the GUI as an extension of your sample/music artform. It is a way to impress upon users your own style and give them a feel for your sonic personality.

If graphic coding is not your cup of tea, the easiest way to make synth controls and knobs with code is to use PaintCode. I made almost all the graphic elements for this app with PaintCode. I've included the PaintCode source files for most of these UI elements here. You can use them as a starting place to learn how to make controls. You can start with these files and change the color, sizes, etc.

Luckily, I've already included the coding part of handling knobs in this repo. You only have to worry about the graphics.

knob in ib

Or, if you want to just completely use graphics instead of code -

If you'd rather make knobs and controls with a graphic rendering software packgage that exports image frames (or a dedicated tool like KnobMan), here's some example code I wrote demonstrating using images to create knobs here.

Knobs

Code Usage

You are free to:

(1) Use this app as a learning tool.
(2) Re-skin this app (change the graphics), use your own sound samples, and upload to the app store.
(3) Change the graphics, use your own sounds, and include this as part of a bigger app you are building.
(4) Contribute code back to this project and improve this code for other people.

If you use any code, it would be great if you gave this project some credit or a mention. The more love this code receives, the better we can make it for everyone. And, always give AudioKit a shout-out when you can! :)

If you make an app with this code, please let us know! We think you're awesome, and would love to hear from you and/or feature your app.

IMPORTANT: You must change the graphics and sounds if you upload this to the app store.

What Sounds Can You Use In Your App?

DX

Please get permission from the content creators before you use any free sounds on the internet. Even if sounds are available for free, it does not mean they are licensed to be used in an interactive app.

The best thing to do is to create or sample your own custom instruments. Generally, you can sample an acoustic instrument or voice without worry. This includes things like Pianos, Flutes, Horns, Human Voice, Guitars, Hand Claps, Foot stomps, etc.

There is a gray area when it comes to keyboards. You can sample pure synthesizers. However, you can not sample keyboards and synthesizers based on PCM or wavetable samples. E.g. A vintage Juno 106 can be legally sampled. But, a modern Juno can not. The modern version uses recorded oscillator waveforms for its source sounds. A Mini-Moog or DX7 can be sampled. But, from the same era, the Roland D-50 or Korg M1 can not. As they use short PCM samples mixed with the oscillators.

More examples: A Korg MS-20 can be sampled. However, a microKORG can not. (As the microKORG uses digital audio samples for its oscillators). Modern soft synths like Massive and

View on GitHub
GitHub Stars548
CategoryContent
Updated9d ago
Forks82

Languages

Swift

Security Score

100/100

Audited on Mar 15, 2026

No findings