Skip to content
Projets

À propos

An accordion for the foldable iPhone Duo. The hinge is the bellows: fold and unfold to play. SwiftUI, onHingeChange, synthesized reeds.

Design et médias

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Accorduon icon

Accorduon

An accordion for the foldable iPhone Duo. The hinge is the bellows: fold and unfold to play.

iOS 27.1+ Xcode 27.1+ Swift 6 SwiftUI MIT License

Download on the App Store

[!NOTE] Accorduon is on the App Store. Download it for iPhone Duo and any other iPhone.

This repository is the open-source demo where it all started. The App Store version has grown since then: more registers and songs, onboarding, motion bellows for iPhones without a hinge, and 7 languages. If you enjoy the demo, the full app is a great way to support the project.

Accorduon on an unfolded iPhone Duo, held in two hands

How to Play

Hold the iPhone Duo open like a book.

  • Right hand plays the melody on the piano keyboard. As on a real accordion, it runs vertically, with low notes at the top.
  • Left hand plays the bass. Black buttons play a single bass note; white buttons play a chord (F, C, G, Dm, Am, Em).
  • Fold and unfold to push air through the reeds. Holding a key doesn't make a sound until the bellows move, and the faster you move the hinge, the louder and brighter it plays.

Pick a song from the menu (Ode to Joy, Twinkle, Twinkle, Jingle Bells, Happy Birthday, or Katyusha) and the next key lights up.

No hinge? Drag the bellows with a finger, or turn on Auto Air to keep them full. Auto Air also helps in the simulator, where a single mouse pointer can't hold a key and fold the device at the same time.

How It Works

The hinge is the bellows. AccordionView listens to onHingeChange and turns the hinge speed, in degrees per second, into air pressure. The air leaks out on its own, so the sound fades as soon as you stop folding. The hinge angle also drives the bellows drawing: the pleats deepen and darken as you fold.

.onHingeChange { _, newContext in
    guard let degrees = newContext.hinge?.angle.degrees else { return }
    let speed = abs(degrees - last.degrees) / seconds
    audio.synth.pump(speed / 120)
}

The sound is synthesized, not sampled. ReedSynth models the parts that make an accordion sound like one:

  • Three reeds per note, tuned −12, 0, and +12 cents. Their beating is the "wet" musette shimmer.
  • A quieter reed an octave below for body.
  • A narrow, anti-aliased (PolyBLEP) pulse for each reed, instead of a raw sawtooth.
  • Two resonances that stand in for the reed chamber.
  • A short pitch bend on attack and air hiss while keys are down.

It renders through an AVAudioSourceNode, with state behind a Mutex.

Multi-touch keys. Both keyboards use SpatialEventGesture, so you can play chords and slide between keys.

Requirements

  • Xcode 27.1+
  • iOS 27.1+ SDK
  • iPhone Duo simulator or device for the hinge. On other devices, drag the bellows or use Auto Air.

Building

xcodebuild -project Accorduon.xcodeproj -scheme Accorduon \
  -destination 'platform=iOS Simulator,name=iPhone Duo' build

Project Structure

Accorduon
├── App          # App entry point and the main screen
├── Audio        # Reed synthesizer and audio engine
├── Instrument   # Bellows, treble keyboard, bass buttons
├── Music        # Notes, songs, and the song bar
└── Resources    # Asset catalog

The Xcode project uses Xcode's JSON project format (project.xcproj). Each source file is listed there with its target membership.

Inspiration

Hinge-controlled games on Android foldables, like Kami, an origami game you play by folding the phone.

For more iPhone Duo APIs, see iPhone Duo by Examples.

Author

Artem Novichkov, https://artemnovichkov.com/

License

The project is available under the MIT license. See the LICENSE file for more info.

Explorer des projets similaires

Chargement…