Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/giginet/ccblowingdetector
https://github.com/giginet/ccblowingdetector
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/giginet/ccblowingdetector
- Owner: giginet
- Created: 2016-01-30T13:04:45.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-15T15:01:08.000Z (almost 9 years ago)
- Last Synced: 2024-10-14T09:53:43.906Z (3 months ago)
- Language: Objective-C
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CCBlowingDetector
It enable to detect blowing via microphone for cocos2d-x
It is implemented for GGJ 2016
This plugin supports iOS only.
# How to integrate
1. All header/implementation in `CCBlowingDetector` directory add to your Xcode project
2. Build and Run# Sample
```cpp
#include "CCBlowingDetector.h"bool YourScene::init() {
auto detector = BlowingDetector::getInstance();
// Initialize detector
// iOS will appears dialog to use microphone when this method was called.
detector->initialize();// Set average threshold.
// When average power exceed this value, it will be detected as blowing.
detector->setAverageThreshold(-5);// Set duration in seconds which required to be detected.
detector->setRequiredBrowingDuration(0.3);// Set callback function when blowing is detected.
detector->setOnDetectedCallback([this](float peak, float average) {
cocos2d::log("detected");
});
// Set callback function when power is updated.
detector->setOnPowerUpdatedCallback([this](float peak, float average) {
cocos2d::log("updated");
});
this->scheduleUpdate();
return true;
}void YourScene::update(float dt)
{
auto detector = BlowingDetector::getInstance();
detector->update(dt);
}```