Skip to content

App architecture

Kartik Venugopal edited this page Apr 12, 2022 · 8 revisions

Home  >  Developer reference  >  App architecture

Aural Player loosely implements the MVC architectural pattern, although it can more accurately be described as implementing an n-tier architecture, consisting of 3 distinct tiers each with its own set of responsibilities.

App layers image

UI layer

The UI layer consists of:

  • The physical views (expressed as XIB files)
  • View controllers, view delegates / data sources, window controllers, and menu controllers
  • Custom view classes

The UI layer receives user commands such as playing a certain track or decreasing the player volume, and passes them on to the Delegate layer, described next.

Delegate layer

The Delegate layer is the middleman between the UI and the back end. It is the "brains" or logic tier of the application, responsible for such duties as:

  • Translating high-level user commands to low-level back end commands (eg. "Next chapter" to "Seek to position 2:34:55")
  • Conversion of user-friendly data values to formats required by the back end (eg. converts "25% Left" to a stereo pan value of "-0.25")
  • Initializing back end components upon app startup, based on user preferences and persisted app state (eg. populating the playlist with the same tracks from the previous app launch)

The Delegate layer consists of several classes simply named XXXDelegate, implementing protocols named XXXDelegateProtocol.

Back End

The core back end components are:

  • Audio Graph (wrapper around AVAudioEngine) - responsible for audio playback and sound manipulation (effects).
  • Player / Scheduler - responsible for track scheduling and initiation / manipulation of track playback (eg. seeking / segment looping).
  • Playlist - a data structure for maintaining the state of, and performing all functions pertaining to, the app's playlist.

Example workflow ("Play next track")

When a user presses the "Next track" button in the Player UI, control flows as described by the workflow illustrated below:

App layers workflow example diagram

  1. PlaybackViewController (in the UI layer) responds to the user action of clicking the "Next track" button, by delegating the request to the Delegate layer below.

  2. PlaybackDelegate (in the Delegate layer) first determines which track needs to play, so it commands SequencerDelegate to select the next track in the current playback sequence. SequencerDelegate does so and returns the track "track3.ogg" to PlaybackDelegate. PlaybackDelegate then delegates the playback request to the Back End layer below, passing the selected track as an argument.

  3. Player (in the Back End layer) delegates the playback request to Scheduler which schedules the track for playback on AuralPlayerNode (part of the Audio Graph), and initiates playback on the node. This completes processing of the user request.

Clone this wiki locally