Exemplo n.º 1
0
void AudioFormatReader::read (AudioSampleBuffer* buffer,
                              int startSample,
                              int numSamples,
                              int64 readerStartSample,
                              bool useReaderLeftChan,
                              bool useReaderRightChan)
{
    jassert (buffer != nullptr);
    jassert (startSample >= 0 && startSample + numSamples <= buffer->getNumSamples());

    if (numSamples > 0)
    {
        const int numTargetChannels = buffer->getNumChannels();

        if (numTargetChannels <= 2)
        {
            int* const dest0 = reinterpret_cast<int*> (buffer->getWritePointer (0, startSample));
            int* const dest1 = reinterpret_cast<int*> (numTargetChannels > 1 ? buffer->getWritePointer (1, startSample) : nullptr);
            int* chans[3];

            if (useReaderLeftChan == useReaderRightChan)
            {
                chans[0] = dest0;
                chans[1] = numChannels > 1 ? dest1 : nullptr;
            }
            else if (useReaderLeftChan || (numChannels == 1))
            {
                chans[0] = dest0;
                chans[1] = nullptr;
            }
            else if (useReaderRightChan)
            {
                chans[0] = nullptr;
                chans[1] = dest0;
            }

            chans[2] = nullptr;
            read (chans, 2, readerStartSample, numSamples, true);

            // if the target's stereo and the source is mono, dupe the first channel..
            if (numTargetChannels > 1 && (chans[0] == nullptr || chans[1] == nullptr))
                memcpy (dest1, dest0, sizeof (float) * (size_t) numSamples);
        }
        else if (numTargetChannels <= 64)
        {
            int* chans[65];
            readChannels (*this, chans, buffer, startSample, numSamples, readerStartSample, numTargetChannels);
        }
        else
        {
            HeapBlock<int*> chans ((size_t) numTargetChannels);
            readChannels (*this, chans, buffer, startSample, numSamples, readerStartSample, numTargetChannels);
        }

        if (! usesFloatingPointData)
            for (int j = 0; j < numTargetChannels; ++j)
                if (float* const d = buffer->getWritePointer (j, startSample))
                    FloatVectorOperations::convertFixedToFloat (d, reinterpret_cast<const int*> (d), 1.0f / 0x7fffffff, numSamples);
    }
}
Exemplo n.º 2
0
int Patch::read(const string &file)
{
  jRoot = json_load_file(file.c_str(), 0, &jError);
  if (!jRoot) {
    gu_log("[Patch::read] unable to read patch file! Error on line %d: %s\n", jError.line, jError.text);
    return PATCH_UNREADABLE;
  }

  if (!checkObject(jRoot, "root element"))
    return PATCH_INVALID;

  init();

  /* TODO json_decref also when PATCH_INVALID */

  if (!readCommons(jRoot))  return setInvalid();
  if (!readColumns(jRoot))  return setInvalid();
  if (!readChannels(jRoot)) return setInvalid();
#ifdef WITH_VST
  if (!readPlugins(jRoot, &masterInPlugins, PATCH_KEY_MASTER_IN_PLUGINS))   return setInvalid();
  if (!readPlugins(jRoot, &masterOutPlugins, PATCH_KEY_MASTER_OUT_PLUGINS)) return setInvalid();
#endif

  json_decref(jRoot);

  sanitize();

  return PATCH_READ_OK;
}
Exemplo n.º 3
0
///////////////////////////////////////////////////////////////////////
// Class				:	CPointHierarchy
// Method				:	CPointHierarchy
// Description			:
/// \brief					Ctor
// Return Value			:
// Comments				:
CPointHierarchy::CPointHierarchy(const char *n,const float *from,const float *to,FILE *in) : CMap<CPointCloudPoint>(), CTexture3d(n,from,to) {
	
	// Try to read the point cloud

	// Read the header
	readChannels(in);
	
	// Read the points
	CMap<CPointCloudPoint>::read(in);

	// Reserve the actual space
	data.reserve(numItems*dataSize);
	
	// Read the data
	fread(data.array,sizeof(float),numItems*dataSize,in);
	data.numItems	=	numItems*dataSize;

	// Close the file
	fclose(in);

	// Find the indices for area and radiosity
	areaIndex		=	-1;
	radiosityIndex	=	-1;
	int	i;
	for (i=0;i<numChannels;i++) {
		if		((strcmp(channels[i].name,areaName) == 0)		&& (channels[i].numSamples == 1))	areaIndex		=	channels[i].sampleStart;
		else if ((strcmp(channels[i].name,radiosityName) == 0)	&& (channels[i].numSamples == 3))	radiosityIndex	=	channels[i].sampleStart;
	}

	// Compute the point hierarchy so that we can perform lookups
	computeHierarchy();
}
Exemplo n.º 4
0
extern void timerCallback(timer_id const id) 
{
    uint8 hacksplack = 0;    
    uint8 minimap =  (g_eeg_serv_data.channel_map & 0x00FF);

    if ((minimap & 0x01) == 1)
        hacksplack += 1;
    if ((minimap & 0x02) == 2)
        hacksplack += 2;
    if ((minimap & 0x04) == 4)
        hacksplack += 4;
    if ((minimap & 0x08) == 8)
        hacksplack += 8;
    if ((minimap & 0x10) == 16)
        hacksplack += 16;
    if ((minimap & 0x20) == 32)
        hacksplack += 32;
    if ((minimap & 0x40) == 64)
        hacksplack += 64;
    if ((minimap & 0x80) == 128)
        hacksplack += 128;
    
    if (hacksplack == 0)
        hacksplack = 1;
    readChannels((hacksplack) , &meas_report[0]);
    
#ifdef DEBUG
   /* writeASCIICodedNumber(minimap);
    DebugWriteString("\r\n");
    writeASCIICodedNumber(hacksplack);
    DebugWriteString("\r\n");
    writeASCIICodedNumber(meas_report[0]);
    DebugWriteString(" ");
    writeASCIICodedNumber(meas_report[1]);
    DebugWriteString("\r\n");
    writeASCIICodedNumber(meas_report[2]);
    DebugWriteString(" ");
    writeASCIICodedNumber(meas_report[3]);
    DebugWriteString("\r\n");
    writeASCIICodedNumber(meas_report[4]);
    DebugWriteString(" ");
    writeASCIICodedNumber(meas_report[5]);
    DebugWriteString("\r\n"); */
#endif
    
    if ((g_eeg_serv_data.acquisition_rate < 1) || (g_eeg_serv_data.acquisition_rate > 900))
        g_eeg_serv_data.acquisition_rate = 10000;

    
    TimerCreate((TIME) (((uint32) g_eeg_serv_data.acquisition_rate) * 100UL), TRUE, timerCallback);
 #ifdef DEBUG   
   
    writeASCIICodedNumber(g_eeg_serv_data.acquisition_rate * 100UL);

    #endif
}
Exemplo n.º 5
0
LoggingConfig::LoggingConfig(const QString& logConfiguration, const QString& logDirectory,
                             const QString& logFilePrefix)
  : logConfig(logConfiguration), logDir(logDirectory), logPrefix(logFilePrefix)
{
  QSettings *settings = nullptr;

  if(!logConfig.isEmpty())
  {
    QFileInfo logFile(logConfig);

    QString logFileInConfig = atools::settings::Settings::getPath() + QDir::separator() + logFile.fileName();

    if(QFile::exists(logFileInConfig))
      // Try in the configuration directory
      settings = new QSettings(logFileInConfig, QSettings::IniFormat);
    else if(QFile::exists(logConfig))
      // Try resource or full path
      settings = new QSettings(logConfig, QSettings::IniFormat);
  }
  else
    // Use default configuration file
    settings = atools::settings::Settings::getQSettings();

  if(settings->status() != QSettings::NoError)
    qWarning() << "Error reading log configuration file" << settings->fileName() << ":" << settings->status();

  // Read general parameters
  readConfigurationSection(settings);

  QHash<QString, QTextStream *> channelMap;
  // Create all file streams and add them to the channelMap
  readChannels(settings, channelMap);

  // Assign log levels to channels
  readLevels(settings, channelMap);

  delete settings;
}
Exemplo n.º 6
0
extern void proc() {
        uint8 data[16];

    
    readChannels(0b11001000, &data[0]);
}
Exemplo n.º 7
0
void GuitarPro5::read(QFile* fp)
      {
      f = fp;
      readInfo();
      readLyrics();
      readPageSetup();

      previousDynamic = -1;
      previousTempo = -1;
      //previousDynamic = new int [staves * VOICES];
      // initialise the dynamics to 0
      //for (int i = 0; i < staves * VOICES; i++)
      //      previousDynamic[i] = 0;

      tempo = readInt();
      if (version > 500)
            skip(1);

      key    = readInt();
      /* int octave =*/ readChar();    // octave

      readChannels();
      skip(42);

      measures = readInt();
      staves  = readInt();

      slurs = new Slur*[staves];
      for (int i = 0; i < staves; ++i)
            slurs[i] = 0;

      int tnumerator   = 4;
      int tdenominator = 4;
      for (int i = 0; i < measures; ++i) {
            if (i > 0)
                  skip(1);
            GpBar bar;
            uchar barBits = readUChar();
            if (barBits & SCORE_TIMESIG_NUMERATOR)
                  tnumerator = readUChar();
            if (barBits & SCORE_TIMESIG_DENOMINATOR)
                  tdenominator = readUChar();
            if (barBits & SCORE_REPEAT_START)
                  bar.repeatFlags = bar.repeatFlags | Repeat::START;
            if (barBits & SCORE_REPEAT_END) {                // number of repeats
                  bar.repeatFlags = bar.repeatFlags |Repeat::END;
                  bar.repeats = readUChar();
                  }
            if (barBits & SCORE_MARKER) {
                  bar.marker = readDelphiString();     // new section?
                  /*int color =*/ readInt();    // color?
                  }
            if (barBits & SCORE_VOLTA) {                      // a volta
                  uchar voltaNumber = readUChar();
                  while (voltaNumber > 0) {
                        // voltas are represented as flags
                        bar.volta.voltaType = GP_VOLTA_FLAGS;
                        bar.volta.voltaInfo.append(voltaNumber & 1);
                        voltaNumber >>= 1;
                        }
                  }
            if (barBits & SCORE_KEYSIG) {
                  int currentKey = readUChar();
                  /* key signatures are specified as
                   * 1# = 1, 2# = 2, ..., 7# = 7
                   * 1b = 255, 2b = 254, ... 7b = 249 */
                  bar.keysig = currentKey <= 7 ? currentKey : -256+currentKey;
                  readUChar();        // specified major/minor mode
                  }
            if (barBits & SCORE_DOUBLE_BAR)
                  bar.barLine = BarLineType::DOUBLE;
            if (barBits & 0x3)
                  skip(4);
            if ((barBits & 0x10) == 0)
                  skip(1);

            readChar();             // triple feel  (none, 8, 16)
            bar.timesig = Fraction(tnumerator, tdenominator);
            bars.append(bar);
            }