sound-fader-ios alternatives and similar libraries
Based on the "Audio" category.
Alternatively, view sound-fader-ios alternatives based on common mentions on social networks and blogs.
-
AudioKit
Swift audio synthesis, processing, & analysis platform for iOS, macOS and tvOS -
EZAudio
An iOS and macOS audio visualization framework built upon Core Audio useful for anyone doing real-time, low-latency audio processing and visualizations. -
StreamingKit
A fast and extensible gapless AudioPlayer/AudioStreamer for OSX and iOS (iPhone, iPad) -
novocaine
Painless high-performance audio on iOS and Mac OS X -
FDWaveformView
Reads an audio file and displays the waveform -
PandoraPlayer
๐ ฟ๏ธ PandoraPlayer is a lightweight music player for iOS, based on AudioKit and completely written in Swift. -
SubtleVolume
Replace the system volume popup with a more subtle indicator. -
SwiftySound
SwiftySound is a simple library that lets you play sounds with a single line of code. -
AudioPlayer
AudioPlayer is syntax and feature sugar over AVPlayer. It plays your audio files (local & remote). -
IQAudioRecorderController
A drop-in universal library allows to record audio within the app with a nice User Interface. -
Jukebox
Player for streaming local and remote audio files. Written in Swift. -
TheAmazingAudioEngine2
The Amazing Audio Engine is a sophisticated framework for iOS audio applications, built so you don't have to. -
MusicKit
A framework for composing and transforming music in Swift -
ESTMusicIndicator
Cool Animated music indicator view written in Swift -
QuietModemKit
iOS framework for the Quiet Modem (data over sound) -
FDSoundActivatedRecorder
Start recording when the user speaks -
ModernAVPlayer
ModernAVPlayer is a persistence AVPlayer wrapper -
AudioPlayerSwift
AudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps. -
Chirp
The easiest way to prepare, play, and remove sounds in your Swift app! -
SRGMediaPlayer-iOS
An advanced media player library, simple and reliable -
BPMAnalyser
Fast and simple instrument to get the BPM rate from your audio-files. -
QHSpeechSynthesizerQueue
Queue management system for AVSpeechSynthesizer
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of sound-fader-ios or a related project?
README
Cephalopod, a sound fader for AvAudioPlayer written in Swift - iOS, tvOS and macOS
This library can help fading sounds in and out with AvAudioPlayer. One can set duration, velocity of the fade and a completion function. Velocity can vary from linear to exponential.
cephalopod = Cephalopod(player: player)
cephalopod?.fadeIn()
Juvenile cuttlefish camouflaged against the seafloor. Photo taken by Raul654. Source: Wikimedia Commons.
Setup
There are three ways you can add Cephalopod to your Xcode project.
Add source (iOS 7+)
Simply add the CephalopodDistrib.swift file to your project.
Setup with Carthage (iOS 8+)
Alternatively, add github "evgenyneu/Cephalopod" ~> 4.0
to your Cartfile and run carthage update
.
Setup with CocoaPods (iOS 8+)
If you are using CocoaPods add this text to your Podfile and run pod install
.
use_frameworks!
target 'Your target name'
pod 'Cephalopod', '~> 4.0'
Legacy Swift versions
Setup a previous version of the library if you use an older version of Swift.
Usage
The following example shows how to play an mp3 file with a fade in effect.
import AVFoundation
import Cephalopod // For CocoaPods and Carthage
// ---
var playerInstance: AVAudioPlayer?
var cephalopod: Cephalopod?
override func viewDidLoad() {
super.viewDidLoad()
// Create a player instance
guard let path = Bundle.main.path(forResource: "squid", ofType: "mp3") else { return }
guard let player = try? AVAudioPlayer(contentsOf: URL(fileURLWithPath: path)) else { return }
playerInstance = player
// Start audio playback
player.play()
player.volume = 0
// Fade in the sound
cephalopod = Cephalopod(player: player)
cephalopod?.fadeIn()
}
Fade in / fade out
cephalopod?.fadeIn()
cephalopod?.fadeOut()
// Supply fade duration and velocity, in seconds
cephalopod?.fadeIn(duration: 3, velocity: 2)
cephalopod?.fadeOut(duration: 3, velocity: 2)
// Supply finish closure
cephalopod?.fadeIn(duration: 3, velocity: 2) { finished in }
cephalopod?.fadeOut(duration: 3, velocity: 2) { finished in }
Supply fade start/end volume and completion callback
cephalopod?.fade(fromVolume: 0.3, toVolume: 0.7, duration: 3, velocity: 2) { finished in
print("Finished fading")
}
Arguments:
fromVolume
- the start volume, a number between 0 and 1.
toVolume
- the end volume, a number between 0 and 1.
duration
- duration of the fade, in seconds. Default duration: 3 seconds.
velocity
- a number specifying how fast the sound volume is changing. Velocity of 0 creates a linear fade. Values greater than zero produce more exponential fade affect. Exponential fade sounds more gradual to a human ear. The fade sounds most natural with velocity parameter from 2 to 5. Default value: 2.
onFinished
- an optional closure that will be called after the fade has ended. The closure will be passed a boolean parameter finished
indicating whether the fading has reached its end value (true
) or if the fading has been cancelled (false
).
Set the quality of fade
cephalopod?.volumeAlterationsPerSecond = 20
Larger numbers will produce finer fade effect at expense of CPU juice. Default value: 30
.
Stop the volume change
One can cancel the ongoing volume change by calling the stop()
method. Note that it stops changing the volume but does not stop the playback.
cephalopod?.stop()
Volume functions
The following graph shows how sound volume changes during the fade.
Fade in formula
Fade out formula
Where x
is time and v
is velocity.
Velocity of 0 creates a linear fade. Values greater than zero produce more exponential fade affect. Exponential fade sounds more gradual to a human ear. I personally use velocity values from 2 to 5.
Live graph demo: https://www.desmos.com/calculator/wnstesdf0h
Demo app
Alternative solutions
Here is a list of other sound libraries for iOS.
Thanks ๐
- nschucky for updating to Swift 2.2 selector syntax.
Credits
The lovely music was recorded by Carlos Vallejo.
"Juvenile cuttlefish camouflaged against the seafloor" photo was taken by Raul654. Source: Wikimedia Commons.
License
Cephalopod is released under the [MIT License](LICENSE).
Feedback is welcome
If you notice any issue, got stuck or just want to chat feel free to create an issue. I will be happy to help you.
*Note that all licence references and agreements mentioned in the sound-fader-ios README section above
are relevant to that project's source code only.