SettingsWindow::SettingsWindow(const String &          title,
                               const String &          execType,
                               const ApplicationInfo & appInfo,
                               String &                endpointToUse,
                               String &                tagToUse,
                               String &                portToUse,
                               int &                   tagModifierCount,
                               StringArray &           argsToUse)  :
    inherited1(), inherited2(), inherited3(title, kWindowBackgroundColour, 0), inherited4(),
    _topText("topText"), _cancelButton("Cancel"), _okButton("OK"),
    _descriptors(appInfo._argDescriptions),
    _errorFont(Font::getDefaultMonospacedFontName(), FormField::kFontSize,
               Font::italic + Font::bold), _regularFont(Font::getDefaultMonospacedFontName(),
                                                        FormField::kFontSize, Font::plain),
    _execType(execType), _extraArgumentsGroup(NULL), _tagModifierGroup(NULL),
    _addArgumentsButton(NULL), _removeArgumentsButton(NULL), _endpointField(NULL), _portField(NULL),
    _tagField(NULL),
    _endpointDescriptor(new Utilities::ChannelArgumentDescriptor(kEndpointFieldName.toStdString(),
                                                                 "", Utilities::kArgModeOptional,
                                                                 "")),
    _portDescriptor(new Utilities::PortArgumentDescriptor(kPortFieldName.toStdString(), "",
                                                          Utilities::kArgModeOptional, 0, false)),
    _appInfo(appInfo), _endpointToUse(endpointToUse), _portToUse(portToUse), _tagToUse(tagToUse),
    _argsToUse(argsToUse), _tagModifierCount(tagModifierCount), _canSetEndpoint(false),
    _canSetPort(false), _canSetTag(false), _canUseModifier(false), _hasExtraArguments(false),
    _hasFileField(false)
{
    ODL_ENTER(); //####
    ODL_S2s("title = ", title.toStdString(), "execType = ", execType.toStdString()); //####
    ODL_P4("appInfo = ", &appInfo, "endpointToUse = ", &endpointToUse, "tagToUse = ", //####
           &tagToUse, "portToUse = ", &portToUse); //####
    ODL_P1("argsToUse = ", &argsToUse); //####
    _contentArea.setSize(100, 100);
    setContentNonOwned(&_contentArea, true);
    BorderSize<int> bt = getBorderThickness();
    BorderSize<int> cb = getContentComponentBorder();
    int             heightSoFar = 0;
    int             widthSoFar = 0;

    _argsToUse.clear();
    _canSetEndpoint = appInfo._options.contains("e");
    _canSetPort = appInfo._options.contains("p");
    _canSetTag = appInfo._options.contains("t");
    _canUseModifier = appInfo._options.contains("m");
    setUpStandardFields(widthSoFar, heightSoFar);
    int minW = jmax(widthSoFar, _cancelButton.getWidth() + _okButton.getWidth() +
                    (3 * FormField::kButtonGap));
    int calcW = minW + bt.getLeftAndRight() + cb.getLeftAndRight();
    int calcH = heightSoFar + bt.getTopAndBottom() + cb.getTopAndBottom();

    centreWithSize(calcW + kExtraSpaceInWindow, calcH + kExtraSpaceInWindow);
    adjustFields();
    setOpaque(true);
    setResizable(false, false);
    setVisible(true);
    addKeyListener(CommonVisuals::GetApplicationCommandManager().getKeyMappings());
    triggerAsyncUpdate();
    ODL_EXIT_P(this); //####
} // SettingsWindow::SettingsWindow
void
GraphicsPanel::setShaderProgram(const String & vertexShader,
                                const String & fragmentShader)
{
    ODL_OBJENTER(); //####
    ODL_S2s("vertexShader = ", vertexShader.toStdString(), "fragmentShader = ", //####
            fragmentShader.toStdString()); //####
    _vertexShaderSource = vertexShader;
    _fragmentShaderSource = fragmentShader;
    ODL_OBJEXIT(); //####
} // GraphicsPanel::setShaderProgram
Beispiel #3
0
void ModulatorSamplerSound::selectSoundsBasedOnRegex(const String &regexWildcard, ModulatorSampler *sampler, SelectedItemSet<ModulatorSamplerSound::Ptr> &set)
{
	bool subtractMode = false;

	bool addMode = false;

	String wildcard = regexWildcard;

	if (wildcard.startsWith("sub:"))
	{
		subtractMode = true;
		wildcard = wildcard.fromFirstOccurrenceOf("sub:", false, true);
	}
	else if (wildcard.startsWith("add:"))
	{
		addMode = true;
		wildcard = wildcard.fromFirstOccurrenceOf("add:", false, true);
	}
	else
	{
		set.deselectAll();
	}


    try
    {
		std::regex reg(wildcard.toStdString());

		ModulatorSampler::SoundIterator iter(sampler, false);

		while (auto sound = iter.getNextSound())
		{
			const String name = sound->getPropertyAsString(Property::FileName);

			if (std::regex_search(name.toStdString(), reg))
			{
				if (subtractMode)
				{
					set.deselect(sound.get());
				}
				else
				{
					set.addToSelection(sound.get());
				}
			}
		}
	}
	catch (std::regex_error e)
	{
		debugError(sampler, e.what());
	}
}
void
YarpLaunchThread::run(void)
{
    ODL_OBJENTER(); //####
    _yarpProcess = new ChildProcess;
    if (_yarpProcess)
    {
        ODL_LOG("_yarpProcess"); //####
        StringArray nameAndArgs(_yarpPath);

        nameAndArgs.add("server");
        nameAndArgs.add("--ip");
        nameAndArgs.add(_yarpAddress);
        nameAndArgs.add("--socket");
        nameAndArgs.add(String(_yarpPort));
        nameAndArgs.add("--write");
        if (_yarpProcess->start(nameAndArgs, 0))
        {
            ODL_LOG("(_yarpProcess->start(nameAndArgs, 0))"); //####
            const String childOutput(_yarpProcess->readAllProcessOutput());

            LazyLaunchProcess(*_yarpProcess, -1);
            ODL_S1s("childOutput = ", childOutput.toStdString()); //####
        }
        else
        {
            ODL_LOG("! (_yarpProcess->start(nameAndArgs, 0))"); //####
        }
    }
    ODL_OBJEXIT(); //####
} // YarpLaunchThread::run
void ProjectManagerApp::fileDrop(FileDropEvent event)
{
	StringArray drops;

	for (auto it : event.getFiles())
	{
		std::string path = it.string();

		File file(path);
		if (file.exists())
		{
			drops.addIfNotAlreadyThere(path);
		}
	}

	CI_ASSERT(drops.size() == 1);

	int count = handler.processCinderRoot(*drops.begin());
	if (count < 0)
	{
		gui->postWarningMessage("Fatal error! ", "Dropped folder is not Cinder root folder");
	}
	else
	{
		String msg = String(count) + " vc2015 projects created!";
		gui->postInfoMessage("Done ", msg.toStdString());
	}
}
Beispiel #6
0
unique_ptr<PositionableAudioSource> getReader(
    const String& name, SampleTime begin, SampleTime end, float sampleRate,
    int channels) {
    unique_ptr<AudioFormatReader> reader(MANAGER->createReaderFor(File(name)));

    if (not reader.get()) {
        DLOG(ERROR) << "Can't read file " << name.toStdString();
        return nullptr;
    }

    if (end < 0)
        end = reader->lengthInSamples;

    if (begin or end < reader->lengthInSamples)
        reader.reset(new AudioSubsectionReader(reader.release(), begin, end, true));

    auto inputSampleRate = reader->sampleRate;
    unique_ptr<PositionableAudioSource> source(
        new AudioFormatReaderSource(reader.release(), true));
    source->setLooping(true);

    if (static_cast<int>(sampleRate) != static_cast<int>(inputSampleRate)) {
        auto ratio = inputSampleRate / sampleRate;
        source.reset(new ResamplingPositionableAudioSource(
            source.release(), true, ratio, channels));
    }
    return source;
}
void MapperInterface::run()
{
    DBG("starting mapper interface thread...\n");
    while (!threadShouldExit())
    {
        //do stuff here...
        int idx=0;
        if (myMapperOut != NULL)
        {
            myMapperOut->poll();
            for (int i=0; i<kNUM_ICUBEX_SENSORS; i++)
            {
                String signame = "/sensor" + String(i);
                int sensorVal = mySigVals.at(idx);
                
                //note: we assume this signal exists, which may not be the case!
                myMapperOut->signal(signame.toStdString()).update(sensorVal);
            }
            
            sleep(50); //lets not be too hasty here...
            
        }
    }
    if (myMapperOut != NULL) {
        delete myMapperOut;
    }
    DBG("ending mapper interface thread...\n");
}
MapperInterface::MapperInterface() : Thread("MapperInterfaceThread")
{
    myMapperOut = new mapper::Device("ICubeX");
    //int min[8] = {  0,   0,   0,   0,   0,   0,   0,   0};
    //int max[8] = {127, 127, 127, 127, 127, 127, 127, 127};
    int min = 0;
    int max = 127;
    //myMapperOut->add_output("/ICubeXSensors", kNUM_ICUBEX_SENSORS, 'i', "raw", &min, &max);
    
    mySigVals.reserve(kNUM_ICUBEX_SENSORS);
    for (int i=0; i<kNUM_ICUBEX_SENSORS; i++)
    {
        String signame = "/sensor" + String(i);
        myMapperOut->add_output_signal(signame.toStdString(), 1, 'i', "raw", &min, &max);
        mySigVals.push_back(0);
    }
    //myMapperOut->add_input("/testLoopback", 1, 'f', "Hz", &min, &max, inputHandler, 0);
    
    
    
    
    //    pt2Member = &MapperInterface::DoIt;
    //    int result = (*this.*pt2Member)(12, 'a', 'b');
    //    DBG("DoIT res = " + String(result));
}
Beispiel #9
0
void InstanceProcessor::setStateInformation (const void* data, int sizeInBytes)
{
    ScopedPointer<XmlElement> xml(getXmlFromBinary(data, sizeInBytes));
    if(xml != nullptr)
    {
        if(xml->hasTagName("CamomileSettings"))
        {
            String name = xml->getStringAttribute("name");
            String path = xml->getStringAttribute("path");
            if(File::isAbsolutePath(path))
            {
                File file(path + File::separatorString + name);
                if(!file.exists())
                {
                    file = File(m_path + File::separatorString + name);
                    if(!file.exists())
                    {
                        file = File(File::getCurrentWorkingDirectory().getFullPathName() + File::separatorString + name);
                        if(!file.exists())
                        {
                            file = File(File::getSpecialLocation(juce::File::SpecialLocationType::userDocumentsDirectory).getFullPathName() + File::separatorString + name);
                            if(!file.exists())
                            {
                                file = File(path + File::separatorString + name);
                            }
                        }
                    }
                }
                loadPatch(name.toStdString(), path.toStdString());
            }
            
            XmlElement* params = xml->getChildByName(juce::StringRef("params"));
            if(params)
            {
                for(int i = 0; i < params->getNumAttributes(); i++)
                {
                    int index = getParameterIndex(params->getAttributeName(i));
                    if(index >= 0)
                    {
                        setParameterNotifyingHost(index, params->getAttributeValue(i).getDoubleValue());
                    }
                }
            }
        }
    }
}
Beispiel #10
0
        PrettyPrinter ()
        {
            String s;
            
            s << "Ripple-" << getVersionString ();

            fullVersionString = s.toStdString ();
        }
void YSE::INTERNAL::logImplementation::logMessage(const String & message) {
  if (level == EL_NONE) return;

  if (funcPtr != nullptr) {
    funcPtr(message.toStdString().c_str());
  } else {
    fileLogger->logMessage(message);
  }
}
        void log (String const& message)
        {
#if BEAST_MSVC
            if (beast_isRunningUnderDebugger ())
                Logger::outputDebugString (message);
#endif

            std::cerr << message.toStdString () << std::endl;
        }
Beispiel #13
0
/* 'fputs' function.
 * The problem is fputs doesn't inserts '\0' symbol at
 * the line end.
 * This functions calls fputs and fputc('\0') in the end.
 */
void rfc::String::putToFile(const String &str, FILE *fileOut)
{
	std::string stdStr = str.toStdString();

	std::fputs(str.toUtf8().constData(), fileOut);
	std::fputc('\0', fileOut);

	// const char *s = str.toUtf8().constData();
	// String::putToFile(str., fileOut);
} /* end of 'fileSaveStr' function */
Beispiel #14
0
void Frigid::loadConfig() {
	lua_State *L = luaL_newstate();
	mPrefs->setLuaState(L);
	luaL_openlibs(L);

	registerFunctions(L);

	String iHateC = mPrefs->getConfigDir() + "quark_config.lua";
	luaL_dofile(L, iHateC.toStdString().c_str());
}
//-----------------------------------------------------------------------------
void WXGLCanvas::setWindowTitle(const String& text)
{
  wxWindow* win = this;
  while(win->GetParent())
    win = win->GetParent();
  #ifdef wxUSE_UNICODE
    win->SetLabel(text.toStdWString().c_str());
  #else
    win->SetLabel(text.toStdString().c_str());
  #endif
}
Beispiel #16
0
    void logMessage (String const& message)
    {
        if (m_shouldLog)
        {
#if BEAST_MSVC
            if (beast_isRunningUnderDebugger ())
            {
                Logger::outputDebugString (message);
            }
            else
            {
                std::cout << message.toStdString () << std::endl;
            }

#else
            std::cout << message.toStdString () << std::endl;

#endif
        }
    }
Beispiel #17
0
void CodeEditor::save(const String &filename) {
	//TODO: Seek and save changed lines only.

	std::ofstream file;
	
	file.open(mWorkingDirectory.toStdString() + filename.toStdString());

	if (!file.is_open()) {
		//TODO: Error
		here
		return;
	}
Beispiel #18
0
static int runUnitTests (String const& match, String const& format)
{
    bool const shouldLog = format != "junit";

    if (format != "junit" && format != "text" && format != "")
    {
        String s;
        s << "Warning, unknown unittest-format='" << format << "'";
        Log::out () << s.toStdString ();
    }

    RippleUnitTests tr (shouldLog);

    tr.runSelectedTests (match);

    if (format == "junit")
    {
        UnitTestUtilities::JUnitXMLFormatter f (tr);

        String const s = f.createDocumentString ();

        std::cout << s.toStdString ();
    }
    else
    {
        UnitTests::Results const& r (tr.getResults ());

        String s;

        s << "Summary: " <<
            String (r.suites.size ()) << " suites, " <<
            String (r.cases) << " cases, " <<
            String (r.tests) << " tests, " <<
            String (r.failures) << " failure" << ((r.failures != 1) ? "s" : "") << ".";

        tr.logMessage (s);
    }

    return tr.anyTestsFailed () ? EXIT_FAILURE : EXIT_SUCCESS;
}
Beispiel #19
0
SynthSlider::SynthSlider(String name) : Slider(name), bipolar_(false), flip_coloring_(false),
                                        active_(true),
                                        string_lookup_(nullptr), parent_(nullptr) {
  if (!mopo::Parameters::isParameter(name.toStdString()))
    return;

  mopo::ValueDetails details = mopo::Parameters::getDetails(name.toStdString());
  if (details.steps)
    setRange(details.min, details.max, (details.max - details.min) / (details.steps - 1));
  else
    setRange(details.min, details.max);

  post_multiply_ = details.display_multiply;
  scaling_type_ = details.display_skew;
  units_ = details.display_units;
  setDoubleClickReturnValue(true, details.default_value);
  setTextBoxStyle(Slider::NoTextBox, true, 0, 0);

  setBufferedToImage(true);
  setColour(Slider::backgroundColourId, Colour(0xff303030));
  setColour(Slider::textBoxOutlineColourId, Colour(0x00000000));
}
Beispiel #20
0
void LoadSave::loadControls(SynthBase* synth,
                            const NamedValueSet& properties) {
  mopo::control_map controls = synth->getControls();
  for (auto control : controls) {
    String name = control.first;
    if (properties.contains(name)) {
      mopo::mopo_float value = properties[name];
      control.second->set(value);
    }
    else {
      mopo::ValueDetails details = mopo::Parameters::getDetails(name.toStdString());
      control.second->set(details.default_value);
    }
  }
}
Beispiel #21
0
Pool EssentiaExtractor::loadDataset(const String& jsonFilename)
{
    Pool pool;
    
    //We get the overall pool, merge and output
    Algorithm* yamlInput  = AlgorithmFactory::create("YamlInput", "format", "json");
    yamlInput->configure("filename", jsonFilename.toStdString());
    yamlInput->output("pool").set(pool);
    yamlInput->compute();
    
    delete yamlInput;
    this->globalOnsetPool = pool;
    
    return pool;
}
Beispiel #22
0
void ArduinoOutput::setDevice(String devName)
{

    if (!acquisitionIsActive)
    {

        Time timer;

        arduino.connect(devName.toStdString());

        if (arduino.isArduinoReady())
        {

            uint32 currentTime = timer.getMillisecondCounter();

            arduino.sendProtocolVersionRequest();
            timer.waitForMillisecondCounter(currentTime + 2000);
            arduino.update();
            arduino.sendFirmwareVersionRequest();

            timer.waitForMillisecondCounter(currentTime + 4000);
            arduino.update();

            std::cout << "firmata v" << arduino.getMajorFirmwareVersion()
                      << "." << arduino.getMinorFirmwareVersion() << std::endl;

        }

        if (arduino.isInitialized())
        {

            std::cout << "Arduino is initialized." << std::endl;
            arduino.sendDigitalPinMode(outputChannel, ARD_OUTPUT);
            CoreServices::sendStatusMessage(("Arduino initialized at" + devName));
            deviceSelected = true;
        }
        else
        {
            std::cout << "Arduino is NOT initialized." << std::endl;
			CoreServices::sendStatusMessage(("Arduino could not be initialized at" + devName));
        }
    } else {
		CoreServices::sendStatusMessage("Cannot change device while acquisition is active.");
    }


}
Beispiel #23
0
void EssentiaExtractor::readYamlToMatrix(const String& yamlFilename, const StringArray& featureList)
{
    using namespace cv;
    
    FileStorage::FileStorage fs2(yamlFilename.toStdString(), FileStorage::READ);
    
    FileNode features = fs2["erbHi"];
    
    std::cout << (float)features[0];
    
    
//    // first method: use (type) operator on FileNode.
//    int frameCount = (int)fs2["frameCount"];
//    
//    std::string date;
//    // second method: use FileNode::operator >>
//    fs2["calibrationDate"] >> date;
//    
//    Mat cameraMatrix2, distCoeffs2;
//    fs2["cameraMatrix"] >> cameraMatrix2;
//    fs2["distCoeffs"] >> distCoeffs2;
//    
//    cout << "frameCount: " << frameCount << endl
//    << "calibration date: " << date << endl
//    << "camera matrix: " << cameraMatrix2 << endl
//    << "distortion coeffs: " << distCoeffs2 << endl;
//    
//    FileNode features = fs2["features"];
//    FileNodeIterator it = features.begin(), it_end = features.end();
//    int idx = 0;
//    std::vector<uchar> lbpval;
//    
//    // iterate through a sequence using FileNodeIterator
//    for( ; it != it_end; ++it, idx++ )
//    {
//        cout << "feature #" << idx << ": ";
//        cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"] << ", lbp: (";
//        // you can also easily read numerical arrays using FileNode >> std::vector operator.
//        (*it)["lbp"] >> lbpval;
//        for( int i = 0; i < (int)lbpval.size(); i++ )
//            cout << " " << (int)lbpval[i];
//        cout << ")" << endl;
//    }

    fs2.release();
}
void
GraphicsPanel::updateShader(void)
{
    ODL_OBJENTER(); //####
    if (_vertexShaderSource.isNotEmpty() || _fragmentShaderSource.isNotEmpty())
    {
        ScopedPointer<OpenGLShaderProgram> aProg(new OpenGLShaderProgram(_context));
        
        if (aProg->addVertexShader(_vertexShaderSource) &&
            aProg->addFragmentShader(_fragmentShaderSource) && aProg->link())
        {
            _shaderProgram = aProg;
            ODL_P1("_shaderProgram <- ", _shaderProgram); //####
            _shaderProgram->use();
            // Remember the vertex attributes
            _positionAttribute = createAttribute(_context, *_shaderProgram, "position");
            _normalAttribute = createAttribute(_context, *_shaderProgram, "normal");
            _sourceColourAttribute = createAttribute(_context, *_shaderProgram, "sourceColour");
            _textureCoordInAttribute = createAttribute(_context, *_shaderProgram, "texureCoordIn");
            ODL_P4("_positionAttribute <- ", _positionAttribute, "_normalAttribute <- ", //####
                   _normalAttribute, "_sourceColourAttribute <- ", _sourceColourAttribute, //####
                   "_textureCoordInAttribute <- ", _textureCoordInAttribute); //####
  
            // Remember the uniform attributes
            _offsetUniform = createUniform(_context, *_shaderProgram, "offset");
            _projectionMatrixUniform = createUniform(_context, *_shaderProgram, "projectionMatrix");
            _viewMatrixUniform = createUniform(_context, *_shaderProgram, "viewMatrix");
            _textureUniform = createUniform(_context, *_shaderProgram, "theTexture");
            _lightPositionUniform = createUniform(_context, *_shaderProgram, "lightPostion");
            ODL_P4("_projectionMatrixUniform <- ", _projectionMatrixUniform, //####
                   "_viewMatrixUniform <- ", _viewMatrixUniform, "_textureUniform <- ", //####
                   _textureUniform, "_lightPositionUniform <- ", _lightPositionUniform); //####
        }
        else
        {
            String lastError = aProg->getLastError();
            
            ODL_LOG("! (aProg->addVertexShader(_vertexShaderSource) && " //####
                    "aProg->addFragmentShader(_fragmentShaderSource) && aProg->link())"); //####
            ODL_S1s("lastError = ", lastError.toStdString()); //####
        }
        _vertexShaderSource = String::empty;
        _fragmentShaderSource = String::empty;
    }
    ODL_OBJEXIT(); //####
} // GraphicsPanel::updateShader
Beispiel #25
0
void LoadSave::loadControls(mopo::HelmEngine* synth,
                            const CriticalSection& critical_section,
                            const NamedValueSet& properties) {
    ScopedLock lock(critical_section);

    mopo::control_map controls = synth->getControls();
    for (auto control : controls) {
        String name = control.first;
        if (properties.contains(name)) {
            mopo::mopo_float value = properties[name];
            control.second->set(value);
        }
        else {
            mopo::ValueDetails details = mopo::Parameters::getDetails(name.toStdString());
            control.second->set(details.default_value);
        }
    }
}
Beispiel #26
0
    Status fetch (void const* key, NodeObject::Ptr* pObject)
    {
        pObject->reset ();

        Status status (unknown);

        void* v (nullptr);
        std::size_t vsize;

        int rc (sp_get (m_db, key, m_keyBytes, &v, &vsize));

        if (rc == 1)
        {
            DecodedBlob decoded (key, v, vsize);

            if (decoded.wasOk ())
            {
                *pObject = decoded.createObject ();
                status = ok;
            }
            else
            {
                status = dataCorrupt;
            }

            ::free (v);
        }
        else if (rc == 0)
        {
            status = notFound;
        }
        else
        {
            String s;
            s << "Sophia failed with error code " << rc;
            Throw (std::runtime_error (s.toStdString()), __FILE__, __LINE__);
            status = notFound;
        }

        return status;
    }
Beispiel #27
0
bool RHD2000Thread::uploadBitfile(String bitfilename)
{
    
    deviceFound = true;
    
    if (!evalBoard->uploadFpgaBitfile(bitfilename.toStdString()))
    {
        std::cout << "Couldn't upload bitfile from " << bitfilename << std::endl;
        
        bool response = AlertWindow::showOkCancelBox (AlertWindow::NoIcon,
                                   "FPGA bitfile not found.",
                                    "The rhd2000.bit file was not found in the directory of the executable. Would you like to browse for it?",
                                     "Yes", "No", 0, 0);
        if (response)
        {
            // browse for file
            FileChooser fc("Select the FPGA bitfile...",
                               File::getCurrentWorkingDirectory(),
                               "*.bit",
                               true);

            if (fc.browseForFileToOpen())
            {
                File currentFile = fc.getResult();
                uploadBitfile(currentFile.getFullPathName()); // call recursively
            }
            else
            {
                //sendActionMessage("No configuration selected.");
                deviceFound = false;
            }

        } else {
            deviceFound = false;
        }

    }
    
    return deviceFound;

}
void MainContentComponent::reset() {

    xpos = winWidth*0.15;
    keyRelease = 0;
    obsX = winWidth*0.95;
    gameStartTime = 0.0f;
    newlifeTime = 0.0f;
    copterHits = 0;
    lifeIdx = 0;

    
    if (myObstacle!= nullptr) {
        delete myObstacle;
    }
    myObstacle = 0;
    
    if (chooseMidi!=nullptr){
        delete chooseMidi;
    }
    chooseMidi = 0;

    chooseMidi = new FileBrowserComponent( FileBrowserComponent::openMode | FileBrowserComponent::canSelectFiles,
                                           File::getSpecialLocation(File::userDesktopDirectory),
                                          &fileFilter, NULL);

    
//    String filePath = File::getCurrentWorkingDirectory().getFullPathName()
//                        + "/stairwayToHeaven.mid";
    
    String filePath = (File::getSpecialLocation(File::currentApplicationFile)).getFullPathName()
                          + "/Contents/Resources/stairwayToHeaven.mid";
    std::cout<<filePath<<std::endl;
    
    myObstacle = new ObstacleComponent(filePath.toStdString().c_str()) ;
    ypos       = myObstacle->getInitialHeight()-35;
    
    isjBMode = false;
    
}
Beispiel #29
0
    void storeBatch (Batch const& batch)
    {
        EncodedBlob::Pool::ScopedItem item (m_blobPool);

        for (Batch::const_iterator iter (batch.begin());
            iter != batch.end(); ++iter)
        {
            EncodedBlob& encoded (item.getObject ());
            encoded.prepare (*iter);

            int rv (sp_set (m_db,
                encoded.getKey(), m_keyBytes,
                    encoded.getData(), encoded.getSize()));

            if (rv != 0)
            {
                String s;
                s << "Sophia failed with error code " << rv;
                Throw (std::runtime_error (s.toStdString()), __FILE__, __LINE__);
            }
        }
    }
Beispiel #30
0
String EssentiaExtractor::buildDataset(const File& audioFolder, bool writeOnsets)
{
    sliceID = 0;
    
    Array<File> filesToProcess = getAudioFiles(audioFolder);
    
    String outputRoot = audioFolder.getFullPathName() + "/dataset/";
    File datasetDirectory(outputRoot);

    datasetDirectory.createDirectory();

    globalOnsetPool.clear();
    
    File fileNames(outputRoot + "filesProcessed.txt");
    
    for(int i=0; i<filesToProcess.size(); i++) {
        String currentAudioFileName = filesToProcess[i].getFileName();
        
        std::cout << "Processing file: " << currentAudioFileName << "\n";
        fileNames.appendText(filesToProcess[i].getFileName() + "\n");
        
        std::cout << "ONE\n";
        
        vector<Real> signal = audioFileToVector(filesToProcess[i]);
        
        std::cout << "TWO\n";
        
        Real BPM =  getGlobalFeatures(signal)[0];
        
        std::cout << BPM << "\n";
        
        //------Onset Processing
        
        //Slice
        vector<Real> onsetTimes = extractOnsetTimes(signal);
        vector<vector<Real> > onsetSlices = extractOnsets(onsetTimes, signal);
        
        
        vector<vector<Real> > loops;
        
        int noOfLoops = 2;
    
        for(int j=0; j<noOfLoops; j++) {
            loops.push_back(randomLoop(onsetTimes, signal, BPM, outputRoot + String((i*noOfLoops)+j) + "_" + currentAudioFileName +  "_loop_" + String(j) + ".wav"));
        }

        Pool onsetPool = extractFeatures(loops, BPM);
        globalOnsetPool.merge(onsetPool, "append");
        
//        writeLoop(onsetTimes[5], signal, BPM, outputRoot + "/testy.wav");
        
        
        //Write
//        if(writeOnsets)
//            this->writeOnsets(onsetSlices, outputRoot);
        
        //Add to pool
//        Pool onsetPool = extractFeatures(onsetSlices, BPM);
        
//        globalOnsetPool.merge(onsetPool, "append");
    }
    
    String jsonFilename = outputRoot + "dataset.json";
    
    //We get the overall pool, merge and output
    Algorithm* yamlOutput  = standard::AlgorithmFactory::create("YamlOutput", "format", "json", "writeVersion", false);
    yamlOutput->input("pool").set(globalOnsetPool);
    yamlOutput->configure("filename", jsonFilename.toStdString());
    yamlOutput->compute();
    
//    File jsonFile(jsonFilename);
//    String jsonFileText = jsonFile.loadFileAsString();
//    jsonFileText = "%YAML:1.0\n" + jsonFileText;
//    jsonFile.replaceWithText(jsonFileText);
    
//    cv::Mat erbHi = poolToMat(pool);      
    
//    cv::Mat poolMat = globalPoolToMat();
    
//    cv::Mat pcaOut = pcaReduce(poolMat, 3);
    return jsonFilename;
}