The easiest way to prepare, play, and remove sounds in your Swift app!

Related tags

Audio Chirp
Overview

Chirp

The easiest way to prepare, play, and remove sounds in your Swift app!

##Installation ###CocoaPods Installation Chirp is available on CocoaPods. Just add the following to your project Podfile:

pod 'Chirp', '~> 1.2'

###Non-CocoaPods Installation You can drop Chirp.swift directly into your project, or drag the Chirp project into your workspace.

Sample code

prepareSound is used to preload a sound into memory. This increases the retain count of the sound by 1. You must call this method before calling playSound

/* MyViewController.swift */

override func viewDidLoad() {
    super.viewDidLoad()
    
    // Load sounds into memory
    Chirp.sharedManager.prepareSound("boop") // default extension is .wav
    Chirp.sharedManager.prepareSound("ding.mp3") // so other extensions you must name explicitly
}

playSound plays the preloaded sound

func submitButtonTouched(button: UIButton) {
    // Since the sound is already loaded into memory, this will play immediately
    Chirp.sharedManager.playSound("boop") 
    
    // example function that might get called when you touch a button
    submitForm() 
}

removeSound removes the sound from memory

deinit {
    // Cleanup is really simple!
    Chirp.sharedManager.removeSound("boop")
    Chirp.sharedManager.removeSound("ding.mp3")
    Chirp.sharedManager.removeSound("oops.mp3")
    
    // If you never loaded the sounds, e.g. viewDidLoad wasn't called, or submission never failed or succeeded,
    // that's ok, because these will function as no-ops
}

Enjoy! I know sound management can be a little annoying. Hopefully this helps your project out a little bit.

You might also like...
Subsonic is a small library that makes it easier to play audio with SwiftUI
Subsonic is a small library that makes it easier to play audio with SwiftUI

Subsonic is a small library that makes it easier to play audio with SwiftUI

SPlayer - play mp3/pm4

SPlayer - play mp3/pm4

FDWaveformView is an easy way to display an audio waveform in your app
FDWaveformView is an easy way to display an audio waveform in your app

FDWaveformView is an easy way to display an audio waveform in your app. It is a nice visualization to show a playing audio file or to select a position in a file.

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display
🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display. Use Apple Keyboard keys or custom shortcuts. Shows the native macOS OSDs.

 A simple way to get a music pitch from a frequency.
A simple way to get a music pitch from a frequency.

Pitchy provides a simple way to get a music pitch from a frequency. Other than that it has a bunch of useful data structures, calculators and helper functions to work with notes, octaves and acoustic waves.

AIB indicates for your app users which audio is playing. Just like the Podcasts app.
AIB indicates for your app users which audio is playing. Just like the Podcasts app.

Audio Indicator Bars for iOS and tvOS Indicates for your app users which audio is playing. Just like the Podcasts app. Index Requirements and Details

SleepingBaby - Track your kids activity and allow them sleep soundly with relaxing music in ONE app
SleepingBaby - Track your kids activity and allow them sleep soundly with relaxing music in ONE app

Sleeping Baby Скачать в AppStore. Ключевые используемые технологии: UIKit, MVVM,

An app to get you the latest and the trending news based on your location.

Newsline Link to APK : http://bit.ly/newslineapp Newsline is an android application made with flutter which makes use of NewsAPI.org to fetch and serv

A macOS app to visualise your iTunes library as graphs.
A macOS app to visualise your iTunes library as graphs.

iTunes Graphs iTunes Graphs is a Cocoa-based macOS app which visualises your iTunes library in a series of pie charts. Currently, it supports the foll

Comments
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    opened by ReadmeCritic 2
  • Swift 3.0 support

    Swift 3.0 support

    Hi. This PR adds support for Swift 3, see #7 The project and test suit were also updated. Please note that the syntax changes slightly, as reflected in the README. If you want to keep the old syntax we can change the lib to use the option first parameter label.

    I would suggest a full version bump for this release (so, 2.0.0), to help late adopters. As for CocoaPods, I suggest using version 1.1.0rc2. You'll find a new file in the repo, called .swift-version that specifies the 3.0 compatibility, and will be used by CP during the trunk push.

    Let me know what you think.

    opened by andreamazz 0
  • linker error

    linker error

    i tried compiling and got this error

    ld: framework not found Chirp clang: error: linker command failed with exit code 1 (use -v to see invocation)

    any suggestions?

    thanks

    julian

    opened by juliankauai 1
Releases(1.0.0)
SoundManager - A simple framework to load and play sounds in your app.

SoundManager - A simple framework to load and play sounds in your app.

Jonathan Chacón 3 Jan 5, 2022
Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way

Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way. You can play

Luis Cárdenas 89 Nov 21, 2022
Analyser BPM in Swift for your music/sounds/records, whatever..

BPM-Analyser Analyser BPM in Swift for your music/sounds/records, whatever.. Powered with Superpowered Preview: How To: Copy theese files to your proj

Gleb Karpushkin 71 Dec 24, 2022
SwiftySound is a simple library that lets you deal with Swift sounds easily

SwiftySound Overview SwiftySound is a simple library that lets you deal with Swift sounds easily. Static methods Sound.play(file: "dog.wav") Sound.pla

Adam Cichy 1.1k Dec 17, 2022
iOS application for finding formants in spoken sounds

FORMANT PLOTTER Buy on the App Store: https://itunes.apple.com/us/app/formant-analyzer/id799183655?mt=8&uo=4&at=11l6hc&ct=fnd This is an iOS project t

William Entriken 51 Dec 25, 2022
Background sounds feature from iOS 15 on iOS 11+

Tranquil Background sounds feature from iOS 15 on iOS 11+ Only physically tested on iOS 14.3 and iOS 12.1.2, but it should support iOS 11 - iOS 15.x (

Dana Buehre 4 Dec 15, 2022
KeyAudioManager - A swift package to make it a lot easier to play audio in your app

KeyAudioManager A swift package to make it a lot easier to play audio in your ap

Pedro Esli 3 Apr 28, 2022
An iOS app that visually clones Spotify's app and consumes the official Spotify's Web API to show(and play) songs, podcasts, artists and more.

SpotifyClone An iOS app that visually clones Spotify's app and consumes the official Spotify's Web API to show(and play) songs, podcasts, artists and

null 104 Jan 7, 2023
Play and share sound inserts from Medo e Delírio em Brasília, a Brazilian podcast.

Play and share sound inserts from Medo e Delírio em Brasília, a Brazilian podcast.

Rafael Schmitt 18 Dec 26, 2022
MusicalInstrument - Play musical instrument in just few lines of swift code

MusicalInstrument Play musical instrument in just few lines of swift code. Requi

null 2 Feb 3, 2022