Beispiel #1
0
void RecordNode::process(AudioSampleBuffer& buffer,
                         MidiBuffer& events)
{
	//update timstamp data even if we're not recording yet
	EVERY_ENGINE->updateTimestamps(&timestamps);
	EVERY_ENGINE->updateNumSamples(&numSamples);
	
	// FIRST: cycle through events -- extract the TTLs and the timestamps
    checkForEvents(events);

    if (isRecording && allFilesOpened)
    {
        // SECOND: write channel data
        if (channelPointers.size() > 0)
        {
            EVERY_ENGINE->writeData(buffer);
        }

        //  std::cout << nSamples << " " << samplesWritten << " " << blockIndex << std::endl;

        return;

    }

    // this is intended to prevent parameter changes from closing files
    // before recording stops
    if (signalFilesShouldClose)
    {
        closeAllFiles();
        signalFilesShouldClose = false;
    }

}
Beispiel #2
0
void RecordNode::process(AudioSampleBuffer& buffer,
                         MidiBuffer& events,
                         int& nSamples)
{

    //std::cout << "Record node processing block." << std::endl;
    //std::cout << "Num channels: " << buffer.getNumChannels() << std::endl;


    if (isRecording)
    {

        //timestamp = timer.getHighResolutionTicks();

        // WHY IS THIS AFFECTING THE LFP DISPLAY?
        //buffer.applyGain(0, nSamples, 5.2438f);

        // cycle through events -- extract the TTLs and the timestamps
        checkForEvents(events);

        // cycle through buffer channels

        if (channelPointers.size() > 0)
        {

            for (int i = 0; i < buffer.getNumChannels(); i++)
            {


                if (channelPointers[i]->isRecording)
                {
                    // write buffer to disk!
                    writeContinuousBuffer(buffer.getSampleData(i),
                                          nSamples,
                                          i);

                    //std::cout << "Record channel " << i << std::endl;
                }


            }
        }



        return;

    }

    // this is intended to prevent parameter changes from closing files
    // before recording stops
    if (signalFilesShouldClose)
    {
        closeAllFiles();
        signalFilesShouldClose = false;
    }

}
Beispiel #3
0
Manager::Manager(QObject* root, QObject *parent) :
    QObject(parent),
    firstFileWasLoaded(false),
    root(root)
{
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), SLOT(moveAllFurther()));

    samplesManager = new SamplesManager(this);
    connect(samplesManager, SIGNAL(haveBeenLoaded(int)), SLOT(haveBeenLoaded(int)));

    findObjects();

    connect(starter, SIGNAL(start()), SLOT(start()));
    connect(starter, SIGNAL(pause()), timer, SLOT(stop()));
    connect(mover, SIGNAL(valueChanged()), SLOT(moveAllToMoverPos()));
    connect(root, SIGNAL(pathsArePrepared()), SLOT(loadData()));
    connect(root, SIGNAL(closeAllFiles()), samplesManager, SLOT(clear()));
    connect(root, SIGNAL(closeAllFiles()), SLOT(resetFileLoadingFlag()));
}
Beispiel #4
0
bool RecordNode::disable()
{
    // close files if necessary
    setParameter(0, 10.0f);

    if (isProcessing)
        closeAllFiles();

    isProcessing = false;

    return true;
}
Beispiel #5
0
void powerFail(void){
    
#ifdef HOSTLCD
    
    // Turn Off the backlight
    turnOffBacklight();
    
#endif
    
#ifdef HOSTUSB
    
    // Close Files and put in suspend mode
    
    closeAllFiles();
    putInSuspendMode();
#endif
    
}
Beispiel #6
0
//---------------------------------------------------------------------------
void MainWindow::closeFile()
{
    if (Files_CurrentPos==(size_t)-1)
        return;
    if (Files.size()==1)
    {
        closeAllFiles();
        return;
    }

    // Launch analysis
    Files.erase(Files.begin()+Files_CurrentPos);
    ui->fileNamesBox->removeItem(Files_CurrentPos);
    if (ui->fileNamesBox->isVisible())
        ui->fileNamesBox->setCurrentIndex(Files_CurrentPos<Files.size()?Files_CurrentPos:Files_CurrentPos-1);
    else
        Files_CurrentPos=Files_CurrentPos<Files.size()?Files_CurrentPos:Files_CurrentPos-1;

    TimeOut();
}
Beispiel #7
0
MenuBar::MenuBar(QWidget *parent) :
    QMenuBar(parent)
{
    fileMenu = new QMenu("File");
    fileMenu->addAction("New", this, SLOT(newFile()), QKeySequence("CTRL+N"));
    fileMenu->addAction("Open", this, SLOT(openFile()), QKeySequence("CTRL+O"));
    // fileMenu->addAction("Open Recent");
    recentMenu = new QMenu("Open recent files");
    fileMenu->addMenu(recentMenu);

    fileMenu->addAction("Save", this, SLOT(saveFile()), QKeySequence("CTRL+S"));
    fileMenu->addAction("Save As...", this, SLOT(saveFileAs()), QKeySequence("SHIFT+CTRL+S"));
    fileMenu->addSeparator();
    fileMenu->addAction("Close", this, SLOT(closeFile()), QKeySequence("CTRL+W"));
    fileMenu->addAction("Close All", this, SLOT(closeAllFiles()), QKeySequence("SHIFT+CTRL+W"));
    fileMenu->addSeparator();
    fileMenu->addAction("Quit", this, SLOT(quit()), QKeySequence("CTRL+Q"));

    sessionMenu = new QMenu("Session");


    editMenu = new QMenu("Edit");
    editMenu->addAction("Previous Buffer", this, SLOT(decrementBuffer()), QKeySequence("ALT+LEFT"));
    editMenu->addAction("Next Buffer", this, SLOT(incrementBuffer()), QKeySequence("ALT+RIGHT"));

    languageMenu = new QMenu("Language");
    languageMenu->addAction("Evaluate code", this, SLOT(evaluateCode()), QKeySequence("SHIFT+RETURN"));
    languageMenu->addAction("Toggle OpenGL", this, SLOT(toggleOpenGL()), QKeySequence("F1"));

    helpMenu = new QMenu("Help");
    helpMenu->addAction("About", this, SLOT(about()));

    addMenu(fileMenu);
    addMenu(sessionMenu);
    addMenu(editMenu);
    addMenu(languageMenu);
    addMenu(helpMenu);
}
Beispiel #8
0
int main( int argc, char ** argv )
{
    int    ch;

    strcpy( progname, "ufdbhttpd" );
    globalPid = getpid();
    globalErrorLog = NULL;

    closeAllFiles();
    ufdbSetGlobalErrorLogFile();

    while ((ch = getopt(argc, argv, "Ddhi:p:I:l:L:U:V")) > 0)
    {
        switch (ch) {
        case 'D':				/* undocumented -D option: do not daemonize */
            runAsDaemon = 0;
            break;
        case 'd':
            UFDBglobalDebug = 1;
            runAsDaemon = 0;
            break;
        case 'i':
            strcpy( interface, optarg );
            break;
        case 'p':
            portnumber = atoi( optarg );
            break;
        case 'I':
            strcpy( imagesDirectory, optarg );
            break;
        case 'l':
            UFDBglobalLogDir = optarg;
            break;
        case 'L':				/* undocumented -L option for alternate PID file */
            globalPidFile = optarg;
            break;
        case 'U':
            if (strlen(optarg) <= 31)
                strcpy( UFDBglobalUserName, optarg );
            else
                ufdbLogFatalError( "username supplied with -U option is too long" );
            break;
        case 'V':
            UFDBglobalDebugHttpd = 1;
            break;
        case '?':
        case 'h':
        default:
            usage();
        }
    }

    if (UFDBglobalLogDir == NULL ||
            imagesDirectory[0] == '\0'  ||
            portnumber <= 0)
    {
        ufdbLogFatalError( "%s started with incorrect parameters. aborting...", progname );
        usage();
        exit( 1 );
    }

    if (runAsDaemon)
    {
        pid_t pid;
        if ((pid = fork()) != 0)		/* the parent exits */
        {
            exit( 0 );
        }
        if (setsid() < 0)
            ufdbLogFatalError( "cannot create daemon session: %s", strerror(errno) );
    }
    globalPid = getpid();

    ufdbSetSignalHandler( SIGPIPE, SIG_IGN );
    ufdbSetSignalHandler( SIGUSR1, USR1signalReceived );
    ufdbSetSignalHandler( SIGHUP,  mySignalHandler );
    ufdbSetSignalHandler( SIGINT,  mySignalHandler );
    ufdbSetSignalHandler( SIGTERM, TermHandler );

    writePidFile();
    atexit( removePidFile );
    ufdbLogMessage( "%s " VERSION " started\ninterface=%s  port=%d  images=%s",
                    progname, interface, portnumber, imagesDirectory );
    if (UFDBglobalDebug)
        ufdbLogMessage( "debug option is ON" );
    if (UFDBglobalDebugHttpd)
        ufdbLogMessage( "HTTP debug option is ON" );
    if (UFDBglobalUserName[0] != '\0')
        ufdbLogMessage( "dropping privileges to user %s", UFDBglobalUserName );

    ufdbSimulateHttpServer( interface, portnumber, UFDBglobalUserName, imagesDirectory, 0 );

    exit( 0 );
    return 0;  /* make compiler happy */
}
Beispiel #9
0
/**
 * Release used memory and close all opened files.
 **/
nrCFileSystem::~nrCFileSystem(){
	if (isVFSOpen){
		closeAllFiles();
	}
}
Beispiel #10
0
void processTerminalCommands(void){
    clearLCD();
   
    // if the user decided to Store info
    // to the USB drive.
    
    #ifdef StoreUSB
    // Check the logging flag,
    // if the logging flag is 1
    if(LoggingState && !ON){
        LoggingState = 0;
        
        //Stop Logging
        closeAllFiles();
        
        //Print to LCD
        goToLine(1);
        LCDprint("Stop logging");
    }
    
    // if the logging flag is 0
    if(!LoggingState && ON){
        LoggingState = 1;
        
        //Start Logging
        openNewFiles();
        
        //Print to LCD
        goToLine(1);
        LCDprint("Start logging");
    } 
    #endif
    
    #ifdef USB
    
    if(HOSTXbee.available() > 0){
        
        char readChar = HOSTXbee.read();
        
        // Options from Terminal:
        //  1 -> start Logging
        //  2 -> stop Logging
        //  3 -> silent Mode
        //       lights off but logging ON
        //  4 -> display files
        //  5 -> delete files
        //  6 -> directory listing
        //  7 -> suspend the VDIP
        //  8 -> set the VDIP to ASCII mode
        //  else -> Error in the input,
        //  Not a recognized input
        
        if(readChar == '1'){
            
            // Start Logging to USB
            goToLine(1);
            LCDprint("Started Logging");
            LoggingState = 1;
            ON = 1;
            
            openNewFiles();
            goToLine(2);
            LCDprint(">");
            
        }else if(readChar == '2'){
            
            // Stop Logging to USB
            goToLine(1);
            LCDprint("Stopped Logging");
            LoggingState = 0;
            ON = 0;
            
            closeAllFiles();
            
            goToLine(2);
            LCDprint(">");
            
        }else if(readChar == '3'){
            
            // Put in silent mode
            goToLine(1);
            LCDprint("Silent mode");
            turnOffBacklight();
            
            goToLine(2);
            LCDprint(">");
            
        }else if(readChar == '4'){
            
            goToLine(1);
            // Print File System
            LCDprint("Files are written to:");
           
            goToLine(2);
            LCDprint("~\\");        
            
            goToLine(3);
            LCDprint("TempData.CSV");
            
            goToLine(4);
            LCDprint("Vitals.CSV");
            
            goToLine(5);
            LCDprint("Others.CSV");
            
            goToLine(6);
            LCDprint("System.txt");
            
            goToLine(7);
            LCDprint("Acknowledge.txt");
            
            goToLine(8);
            LCDprint(">");
            
        }else if(readChar == '5'){
            
            // Delete files
            goToLine(1);
            LCDprint("Deleting files");
            deleteFiles();
            
            goToLine(2);
            LCDprint(">");
            
        }else if(readChar == '6'){
            
            // Show the directory
            goToLine(1);
            LCDprint("DIR:");
            
            goToLine(2);
            readLineFromVDIP();
            
            goToLine(3);
            LCDprint(">");

        }else if(readChar == '7'){
            
            // Suspend the VDIP
            goToLine(1);
            LCDprint("Suspending:");
            putInSuspendMode();
            
            goToLine(2);
            LCDprint(">");            
            
        }else if(readChar == '8'){

            // Set ASCII mode
            setToASCIIMode();
            
            goToLine(1);
            LCDprint("[OK]");
            
            goToLine(2);
            LCDprint("> ");
            
        }else{
            
            // Print Help Menu
            goToLine(1);
            LCDprint("Unrecognised command '");
            LCDprintChar(readChar);
            LCDprint("'");
            
            delay(1000);
            
            goToLine(1);
            LCDprint("1 - Start logging");
            
            goToLine(2);
            LCDprint("2 - Stop logging");
            
            goToLine(3);
            LCDprint("3 - Silent Mode");
            
            goToLine(4);
            LCDprint("4 - Display Logfiles");
            
            goToLine(5);
            LCDprint("5 - Delete Logfiles");
            
            goToLine(6);
            LCDprint("6 - Directory listing");
            
            goToLine(7);
            LCDprint("7 - Suspend VDIP");
            
            goToLine(8);
            LCDprint("8 - Set to ASCII mode");
            
            delay(1000);
            
            goToLine(1);
            LCDprint("> ");
        }
    }
    #else
    
    // Can't print to Serial since we are using the
    // XBee layer, and we can only send AT Commands.
    // Unless the XBee is in API mode we cannot send
    // Serial Commands directly to the Board...
    
    clearLCD();
    
    goToLine(1);
    LCDprint("***ERROR***");
    #endif
}
Beispiel #11
0
void RecordNode::process(AudioSampleBuffer& buffer,
                         MidiBuffer& events,
                         int& nSamples)
{

    // TERMINOLOGY:
    // buffer -- incoming data stored in AudioSampleBuffer (nSamples long)
    // block -- 1024-sample sequence for disk writing (BLOCK_LENGTH long)
    // samplesWritten -- number of samples written from the current buffer
    // blockIndex -- index within the current block (used outside this function)
    // numSamplesToWrite -- number of unwritten samples from the buffer

    // CONSTRAINTS:
    // samplesWritten must equal nSamples by the end of the process() method

    if (isRecording && allFilesOpened)
    {

        // FIRST: cycle through events -- extract the TTLs and the timestamps
        checkForEvents(events);

        // SECOND: cycle through buffer channels
        int samplesWritten = 0;

        if (channelPointers.size() > 0)
        {

            while (samplesWritten < nSamples) // there are still unwritten samples in the buffer
            {

                int numSamplesToWrite = nSamples - samplesWritten; // samples remaining in the buffer

                if (blockIndex + numSamplesToWrite < BLOCK_LENGTH) // we still have space in this block
                {

                    for (int i = 0; i < buffer.getNumChannels(); i++)
                    {

                        if (channelPointers[i]->getRecordState())
                        {
                            // write buffer to disk!
                            writeContinuousBuffer(buffer.getReadPointer(i,samplesWritten),
                                                  numSamplesToWrite,
                                                  i);

                        }
                    }

                    // update our variables
                    samplesWritten += numSamplesToWrite;
                    timestamp += numSamplesToWrite;
                    blockIndex += numSamplesToWrite;

                }
                else // there's not enough space left in this block for all remaining samples
                {

                    numSamplesToWrite = BLOCK_LENGTH - blockIndex;

                    for (int i = 0; i < buffer.getNumChannels(); i++)
                    {

                        if (channelPointers[i]->getRecordState())
                        {
                            // write buffer to disk!
                            writeContinuousBuffer(buffer.getReadPointer(i,samplesWritten),
                                                  numSamplesToWrite,
                                                  i);

                            //std::cout << "Record channel " << i << std::endl;
                        }
                    }

                    // update our variables
                    samplesWritten += numSamplesToWrite;
                    timestamp += numSamplesToWrite;
                    blockIndex = 0; // back to the beginning of the block
                    
                }
            }
        }

        //  std::cout << nSamples << " " << samplesWritten << " " << blockIndex << std::endl;

        return;

    }

    // this is intended to prevent parameter changes from closing files
    // before recording stops
    if (signalFilesShouldClose)
    {
        closeAllFiles();
        signalFilesShouldClose = false;
    }

}
Beispiel #12
0
//---------------------------------------------------------------------------
void MainWindow::on_actionCloseAll_triggered()
{
    closeAllFiles();
}