Esempio n. 1
0
void
OpenSLLayer::init()
{
    initAudioEngine();
    initAudioPlayback();
    initAudioCapture();

    flushMain();
    flushUrgent();
}
Esempio n. 2
0
//!
//! \brief This function accepts MCI-alias and file path. Function used to poke initialization of sound engine and bind custom musics sent by SMBX Engine.
//! \param alias MCI-Alias sent by SMBX Engine
//! \param fileName File path sent by SMBX Engine
//!
void MusicManager::addSound(std::string alias, std::string fileName)
{
    initAudioEngine();

    //Load custom music
    if(alias=="music24") {
        //clear junk
        replaceSubStr(fileName, "\"", "");
        replaceSubStr(fileName, "\\\\",  "\\");
        replaceSubStr(fileName, "/",  "\\");
        music_lvl[23].setPath(fileName);
    }
}
Esempio n. 3
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("HereticTrainer");
        director->setOpenGLView(glview);
	}
	
	// 存放路径
	std::vector<std::string> searchPaths;

	// 得到外部存放音乐目录
	getmyStorage(searchPaths);

	// 在mac平台调试
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
	searchPaths.push_back("Resources/");
	searchPaths.push_back("/Users/ZHP/Animation/Lovelive/LLpractice/Play/");
	printf("%s\n", searchPaths[0].c_str());
#endif
	
	FileUtils::getInstance()->setSearchPaths(searchPaths);
	initAudioEngine();
	// 不显示屏幕信息
    director->setDisplayStats(false);
	// 分辨率匹配
	glview->setDesignResolutionSize(1080, 720, ResolutionPolicy::SHOW_ALL);
    // 设置FPS,每秒刷新60次
    director->setAnimationInterval(1.0 / 60);
	
	if (!UserDefault::getInstance()->getBoolForKey("ok")) {
		UserDefault::getInstance()->setBoolForKey("ok", true);
		UserDefault::getInstance()->setDoubleForKey("rate", 1.0);
		UserDefault::getInstance()->setDoubleForKey("baddis", 144);
		UserDefault::getInstance()->setDoubleForKey("gooddis", 80);
		UserDefault::getInstance()->setDoubleForKey("greatdis", 50);
		UserDefault::getInstance()->setDoubleForKey("perfectdis", 20);
		UserDefault::getInstance()->setDoubleForKey("offsetdis", 0);
		UserDefault::getInstance()->setDoubleForKey("touchdis", 142);
		UserDefault::getInstance()->setDoubleForKey("touchwidth", 80);
		UserDefault::getInstance()->setDoubleForKey("touchheight", 140);
		UserDefault::getInstance()->flush();
	}
	auto scene = SelectSong::createScene();
    director->runWithScene(scene);
    return true;
}
Esempio n. 4
0
std::vector<std::string>
OpenSLLayer::getCaptureDeviceList() const
{
    std::vector<std::string> captureDeviceList;



// Although OpenSL ES specification allows enumerating
// available output (and also input) devices, NDK implementation is not mature enough to
// obtain or select proper one (SLAudioIODeviceCapabilitiesItf, the official interface
// to obtain such an information)-> SL_FEATURE_UNSUPPORTED

    SLuint32 InputDeviceIDs[MAX_NUMBER_INPUT_DEVICES];
    SLint32 numInputs = 0;
    SLboolean mic_available = SL_BOOLEAN_FALSE;
    SLuint32 mic_deviceID = 0;

    SLresult res;

    initAudioEngine();
    initAudioPlayback();
    initAudioCapture();


    // Get the Audio IO DEVICE CAPABILITIES interface, implicit
    DEBUG("Get the Audio IO DEVICE CAPABILITIES interface, implicit");

    res = (*engineObject_)->GetInterface(engineObject_, SL_IID_AUDIOIODEVICECAPABILITIES, (void*)&AudioIODeviceCapabilitiesItf);
    CheckErr(res);

    DEBUG("Get the Audio IO DEVICE CAPABILITIES interface, implicit");
    numInputs = MAX_NUMBER_INPUT_DEVICES;

    res = (*AudioIODeviceCapabilitiesItf)->GetAvailableAudioInputs(AudioIODeviceCapabilitiesItf, &numInputs, InputDeviceIDs);
    CheckErr(res);

    // Search for either earpiece microphone or headset microphone input
    // device - with a preference for the latter
    for (int i = 0; i < numInputs; i++) {
        res = (*AudioIODeviceCapabilitiesItf)->QueryAudioInputCapabilities(AudioIODeviceCapabilitiesItf,
                                                                           InputDeviceIDs[i],
                                                                           (SLAudioInputDescriptor *)&AudioInputDescriptor);
        CheckErr(res);

        if (AudioInputDescriptor.deviceConnection == SL_DEVCONNECTION_ATTACHED_WIRED and
            AudioInputDescriptor.deviceScope == SL_DEVSCOPE_USER and
            AudioInputDescriptor.deviceLocation == SL_DEVLOCATION_HEADSET) {
            DEBUG("SL_DEVCONNECTION_ATTACHED_WIRED : mic_deviceID: %d", InputDeviceIDs[i] );
            mic_deviceID = InputDeviceIDs[i];
            mic_available = SL_BOOLEAN_TRUE;
            break;
        } else if (AudioInputDescriptor.deviceConnection == SL_DEVCONNECTION_INTEGRATED and
                   AudioInputDescriptor.deviceScope == SL_DEVSCOPE_USER and
                   AudioInputDescriptor.deviceLocation == SL_DEVLOCATION_HANDSET) {
            DEBUG("SL_DEVCONNECTION_INTEGRATED : mic_deviceID: %d", InputDeviceIDs[i] );
            mic_deviceID = InputDeviceIDs[i];
            mic_available = SL_BOOLEAN_TRUE;
            break;
        }
    }

    if (!mic_available) {
        // Appropriate error message here
        ERROR("No mic available quitting");
        exit(1);
    }


    return captureDeviceList;
}