Exemple #1
0
FilePlayer::FilePlayer(const String& s): ChangeListener{},
    sampleName{s}, deviceManager{}, formatManager{}, transportSource{},
    filter{&transportSource,false}, sourcePlayer{}, state{Stopped} {
    filter.setCoefficients (IIRCoefficients::makeHighPass (44100,0));

    formatManager.registerBasicFormats();
    sourcePlayer.setSource (&filter);
    deviceManager->addAudioCallback (&sourcePlayer);
    deviceManager->addChangeListener (this);
    transportSource.addChangeListener (this);
    
    if (s != ""){
        File f (sampleName);
        auto r = formatManager.createReaderFor(f);
        if( r == nullptr) {
            //throw BadFormatException("cannot play "+sampleName);
			throw BadFormatException(std::string("cannot play this sample"));
            //delete this;
        }else{
			readerSource = nullptr;
            readerSource = new AudioFormatReaderSource (r,true);
            transportSource.setSource (readerSource);
        }
    }
}
Exemple #2
0
inline void LogCodec::changeELFFormat(char *fmt)
{
	m_format.clear();
	char *ptr;
	bool last_field = false;
	while (!last_field && *fmt != '\0' && m_event_split.find(*fmt) == std::string::npos) {
		// skip leading spaces
		while (*fmt == ' ') ++fmt;
		// find the end of the field name
		ptr = fmt;
		while (*ptr != '\0' && m_event_split.find(*ptr) == std::string::npos && *ptr != ' ') ++ptr;
		// set last_field if we're at the end
		if (*ptr == '\0' || m_event_split.find(*ptr) != std::string::npos) last_field = true;
		*ptr = '\0';
		FieldMap::const_iterator i = m_field_map.find(fmt);
		if (i == m_field_map.end())
			throw BadFormatException(fmt);
		m_format.push_back(i->second);
		fmt = ptr + 1;
	}
}
		unsigned int Texture2D::Create(std::string const&path, tdelegate& deleg) {

			int  iComponents;
			int width, height;

			unsigned char* tex_2d = SOIL_load_image
				(
					path.c_str(),
					&width, &height, &iComponents, SOIL_LOAD_RGBA
					);


			if (tex_2d == 0) {
				const char* description = SOIL_last_result();
				DBOUT(description << "\n");
				throw BadFormatException(path);
			}
			unsigned v = deleg(tex_2d, 4, 0, width, height);

			SOIL_free_image_data(tex_2d);
			return v;
		}