GithubHelp home page GithubHelp logo

ostuda / finch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zoul/finch

1.0 1.0 0.0 1.39 MB

Simple, low-latency OpenAL sound engine for Apple iOS.

Home Page: http://github.com/zoul/Finch/

License: MIT License

finch's Introduction

About

Finch is a simple OpenAL-based sound effect player for iOS. The reasons for writing Finch instead of sticking with Apple’s AVAudioPlayer are described in my question on Stack Overflow. The goals are simple: (1) Play sound effects without much fuss, and (2) do not lag in the play method as AVAudioPlayer does. Finch is not meant to play background music. If you want to play background music, you can go with AVAudioPlayer. Finch will play the sound effects over the background music just fine.

Installing

Finch is a static library. Your best bet is to use the “workspace” Xcode 4 feature, adding the Finch project into your project’s workspace and linking the appropriate target against libFinch. The only remaining thing is taking care of headers. This is a bit clumsy (see another SO question), but in essence you can put Finch into a folder inside your project (say Support) and set the user header search path to this folder and below (Support/**).

Using

In order to use Finch you have to create a factory first:

#import "FISoundEngine.h"
#import "FIFactory.h"
#import "FISound.h"

FIFactory *soundFactory = [[FIFactory alloc] init];

The factory will give you the sound engine:

FISoundEngine *engine = [soundFactory buildSoundEngine];
[engine activateAudioSessionWithCategory:AVAudioSessionCategoryPlayback];
[engine openAudioDevice];

And also the sounds:

FISound *soundA = [soundFactory loadSoundNamed:@"sitar.wav"];
FISound *soundB = [soundFactory loadSoundNamed:@"gun.wav" maxPolyphony:4];
[soundA play];

Sound loaded without the maxPolyphony argument will only play with one “voice” at a time. If you call play before such sound is finished, it will play again from the start:

-----------------> time
ra
  ra
    rapid fire!

If you wish to overlay multiple instances of the sound, set the maxPolyphony argument to maximum number of sounds that you need to layer:

-----------------> time
rapid fire!
  rapid fire!
    rapid fire!

And please note that Finch does not yet support compressed audio. You should be safe with mono or stereo WAV files sampled at 44.1 kHz. There is a demo target inside the project, take a look at it to see more.

Tips

  • You can turn library logging on/off by setting the logger property of the Finch factory. There are two loggers (FILoggerNull and FILoggerNSLog) already included for your convenience and you can easily write your own.

  • You can use the sound classes independently on the sound engine class, for example if you already have some own OpenAL initialization code in place.

  • You can plug in your own decoder if you want to support some other audio formats, see the FISoundDecoder protocol and the soundDecoders property of the factory class.

Links

Some links you might find useful:

License

Licensed under the MIT License. Essentially you can do with this software whatever you like, provided that you keep the copyright notice and the license text along.

Author & Support

Tomáš Znamenáček, [email protected]. Suggestions welcomed.

If you have a question that could possibly be of interest to other people, you can ask it on Stack Overflow and send me a link to your question. It’s better than discussing it in private, because you can get answers from other people and once the question has been answered, other people can benefit from the answer, too.

finch's People

Contributors

zoul avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.