bool FileInputDataSource::open() { if (!mFp) { unsigned int channel; unsigned int sampleRate; audio_format_type_t pcmFormat; audio_type_t audioType; mFp = fopen(mDataPath.c_str(), "rb"); if (!mFp) { medvdbg("file open failed error : %d\n", errno); return false; } audioType = utils::getAudioTypeFromPath(mDataPath); setAudioType(audioType); switch (audioType) { case AUDIO_TYPE_MP3: case AUDIO_TYPE_AAC: if (!utils::header_parsing(mFp, audioType, &channel, &sampleRate, NULL)) { medvdbg("header parsing failed\n"); return false; } setSampleRate(sampleRate); setChannels(channel); break; case AUDIO_TYPE_WAVE: if (!utils::header_parsing(mFp, audioType, &channel, &sampleRate, &pcmFormat)) { medvdbg("header parsing failed\n"); return false; } if (fseek(mFp, WAVE_HEADER_LENGTH, SEEK_SET) != 0) { medvdbg("file seek failed error\n"); return false; } setSampleRate(sampleRate); setChannels(channel); setPcmFormat(pcmFormat); break; case AUDIO_TYPE_FLAC: /* To be supported */ break; default: /* Don't set any decoder for unsupported formats */ break; } return true; } /** return true if mFp is not null, because it means it using now */ return true; }
/* * Add a new PWM instance to this motor controller. * channel - the controller channel from 1 to 10 * pin_number - the index in the PWM array defined in 'setMotors', this is the next blank slot available * dir_pin - the direction pin for this channel * dir_default - the default direction the motor starts in * timer_pre - timer prescale default 1 = no prescale * timer_res - timer resolution in bits - default 8 */ void HBridgeDriver::createPWM(uint8_t channel, uint8_t pin_number, uint8_t dir_pin, uint8_t dir_default, int timer_pre, int timer_res) { // Attempt to assign PWM pin, lock to 8 bits no prescale, mode 2 CTC if( getChannels() < channel ) setChannels(channel); if( assignPin(pin_number) ) { // Set up the digital direction pin if( assignPin(dir_pin) ) { Digital* dpin = new Digital(dir_pin); dpin->pinMode(OUTPUT); for(int i = 0; i < 10; i++) { if(!pdigitals[i]) { pdigitals[i] = dpin; break; } } int pindex; for(pindex = 0; pindex < 10; pindex++) { if( !ppwms[pindex] ) break; } if( ppwms[pindex] ) return; currentDirection[channel-1] = dir_default; defaultDirection[channel-1] = dir_default; motorDrive[channel-1][0] = pindex; motorDrive[channel-1][1] = dir_pin; motorDrive[channel-1][2] = timer_pre; motorDrive[channel-1][3] = timer_res; PWM* ppin = new PWM(pin_number); ppwms[pindex] = ppin; ppwms[pindex]->init(pin_number); } } }
AudioTrack::AudioTrack(TrackType t) : Track(t) { _processed = false; _haveData = false; _sendMetronome = false; _prefader = false; _efxPipe = new Pipeline(); _recFile = 0; _channels = 0; _automationType = AUTO_OFF; setChannels(2); addController(new CtrlList(AC_VOLUME,"Volume", 0.001, 3.16 /* roughly 10 db */)); addController(new CtrlList(AC_PAN, "Pan", -1.0, 1.0)); addController(new CtrlList(AC_MUTE, "Mute", 0.0, 1.0, true /*dont show in Composer */)); _totalOutChannels = MAX_CHANNELS; outBuffers = new float*[_totalOutChannels]; for (int i = 0; i < _totalOutChannels; ++i) posix_memalign((void**) &outBuffers[i], 16, sizeof (float) * segmentSize); // This is only set by multi-channel syntis... _totalInChannels = 0; bufferPos = MAXINT; setVolume(1.0, true); }
ofxPDSPEngine::ofxPDSPEngine(){ inputID = 0; outputID = 0; inStreamActive = false; outStreamActive = false; inputChannels = outputChannels = -1; // for the next method to work setChannels(0, 2); state = closedState; midiIns.reserve(10); controllers.reserve(20); controllerLinkedMidis.reserve(20); externalOuts.reserve(10); midiIns.clear(); controllers.clear(); hasMidiIn = false; hasExternalOut = false; hasOscIn = false; graphics.setParent( score ); ofAddListener( ofEvents().exit, this, &ofxPDSPEngine::onExit ); }
//---------- void Fixture::update() { //calculate DMX vector<DMX::Value> output; for (int i = 0; i < this->channels.size(); i++) { auto channel = this->channels[i]; if (channel->enabled.get() == false) { //break on first disabled channel break; } auto & generator = channel->generateValue; if (generator) { auto value = generator(); channel->value.set(value); } output.push_back(this->channels[i]->value); } //transmit DMX auto transmit = this->getInput<DMX::Transmit>(); if (transmit) { auto universe = transmit->getUniverse(this->universeIndex.get()); if (universe) { universe->setChannels(this->channelIndex.get(), &output[0], output.size()); } else { RULR_ERROR << "Universe index " << this->universeIndex << " is out of bounds for this sender"; } } }
void TrackInfoObject::parse() { // Log parsing of header information in developer mode. This is useful for // tracking down corrupt files. const QString& canonicalLocation = m_fileInfo.canonicalFilePath(); if (CmdlineArgs::Instance().getDeveloper()) { qDebug() << "TrackInfoObject::parse()" << canonicalLocation; } // Parse the information stored in the sound file. SoundSourceProxy proxy(canonicalLocation, m_pSecurityToken); Mixxx::SoundSource* pProxiedSoundSource = proxy.getProxiedSoundSource(); if (pProxiedSoundSource != NULL && proxy.parseHeader() == OK) { // Dump the metadata extracted from the file into the track. // TODO(XXX): This involves locking the mutex for every setXXX // method. We should figure out an optimization where there are private // setters that don't lock the mutex. // If Artist, Title and Type fields are not blank, modify them. // Otherwise, keep their current values. // TODO(rryan): Should we re-visit this decision? if (!(pProxiedSoundSource->getArtist().isEmpty())) { setArtist(pProxiedSoundSource->getArtist()); } if (!(pProxiedSoundSource->getTitle().isEmpty())) { setTitle(pProxiedSoundSource->getTitle()); } if (!(pProxiedSoundSource->getType().isEmpty())) { setType(pProxiedSoundSource->getType()); } setAlbum(pProxiedSoundSource->getAlbum()); setAlbumArtist(pProxiedSoundSource->getAlbumArtist()); setYear(pProxiedSoundSource->getYear()); setGenre(pProxiedSoundSource->getGenre()); setComposer(pProxiedSoundSource->getComposer()); setGrouping(pProxiedSoundSource->getGrouping()); setComment(pProxiedSoundSource->getComment()); setTrackNumber(pProxiedSoundSource->getTrackNumber()); setReplayGain(pProxiedSoundSource->getReplayGain()); setBpm(pProxiedSoundSource->getBPM()); setDuration(pProxiedSoundSource->getDuration()); setBitrate(pProxiedSoundSource->getBitrate()); setSampleRate(pProxiedSoundSource->getSampleRate()); setChannels(pProxiedSoundSource->getChannels()); setKeyText(pProxiedSoundSource->getKey(), mixxx::track::io::key::FILE_METADATA); setHeaderParsed(true); } else { qDebug() << "TrackInfoObject::parse() error at file" << canonicalLocation; setHeaderParsed(false); // Add basic information derived from the filename: parseFilename(); } }
/** * Open the JPG images. * If file exists, the image are loaded in the pixel matrix. * * @param filename: Name of the Image to open. * @exception FileException Throwed when the file does not exists. * @exception FullHeapException Insufficient space for memory allocation. * @see Pixel. */ void JPGImage::openImage(string filename) throw (artemis::FileException*, artemis::FullHeapException*){ IplImage *image; setFilename(filename); image = cvLoadImage(getFilename().c_str(), 3); if (!image) throw new FileException(0, "The image file cannot be opened or the file does not exists", filename); //JPG is a multi channel colored image setChannels(image->nChannels); setImageID(0); //Properties of the Object //Size is the pixel area //Here is the calculus setSize((image->height)*(image->width)); setWidth(image->width); setHeight(image->height); //Transfer RGB from IplImage to Matrix of Pixels //The Matrix of Pixels can be accessed now //Full Load of the jpg image //This function load the JPEG image by OpenCV try{ loadPixelMatrix(); }catch(FullHeapException he){ throw he; } cvReleaseImage(&image); }
void IrcClient::createBufferList() { bufferModel = new IrcBufferModel(connection); connect(bufferModel, SIGNAL(added(IrcBuffer*)), this, SLOT(onBufferAdded(IrcBuffer*))); connect(bufferModel, SIGNAL(removed(IrcBuffer*)), this, SLOT(onBufferRemoved(IrcBuffer*))); bufferList = new QListView(this); bufferList->setFocusPolicy(Qt::NoFocus); bufferList->setModel(bufferModel); // keep the command parser aware of the context connect(bufferModel, SIGNAL(channelsChanged(QStringList)), parser, SLOT(setChannels(QStringList))); // keep track of the current buffer, see also onBufferActivated() connect(bufferList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(onBufferActivated(QModelIndex))); // create a server buffer for non-targeted messages... IrcBuffer* serverBuffer = bufferModel->add(connection->host()); // ...and connect it to IrcBufferModel::messageIgnored() connect(bufferModel, SIGNAL(messageIgnored(IrcMessage*)), serverBuffer, SLOT(receiveMessage(IrcMessage*))); insertWidget(0, bufferList); setStretchFactor(0, 1); setStretchFactor(1, 3); }
//ported from bsnes Resampler::Resampler() { setChannels(2); setPrecision(16); setFrequency(44100.0, 44100.0); setVolume(1.0); clear(); }
AudioStream::AudioStream(std::string langCode, std::string language, std::string format, std::string quantization, std::string frequency, unsigned int channels) { setLangCode(langCode); setLanguage(language); setFormat(format); setQuantization(quantization); setFrequency(frequency); setChannels(channels); }
static void setChannelsIntensity(uint8_t * intensity) { // for all channels and drivers for (uint_fast8_t ii = 0; ii < 10 * DRIVERS; ++ii) { intensity[ii] = intensityToPwm(intensity[ii]); } setChannels(intensity); }
void Controller::recallState(int state) { if (state >= constants::STATE_COUNT) { return; } modular_server_.getSavedVariableValue(constants::states_name,states_array_,state); uint32_t channels = states_array_[state]; setChannels(channels); }
AMBasicXRFDetectorInfo& AMBasicXRFDetectorInfo::operator =(const AMBasicXRFDetectorInfo &other) { if(this != &other){ AMOldDetectorInfo::operator =(other); setElements(other.elements()); setChannels(other.channels()); setIntegrationTime(other.integrationTime()); setPeakingTime(other.peakingTime()); } return *this; }
AudioStream::AudioStream() { setLangCode("na"); setLanguage("undefined"); setLangExtension("undefined"); setFormat("undefined"); setQuantization("undefined"); setFrequency("undefined"); setChannels(0); }
void SoundFile :: open( std::string filename, bool raw, bool doNormalize ) { filename_ = filename; // store the filename for informational purposes if(filename_.size() < 1){ printf("Please give a filename."); } else{ source->openFile( filename, raw, doNormalize ); setChannels(source->getChannels()); source->addTime(100000000000000.0); // this is a sloppy way of making sure that the file does not start by itself } }
void BaseAudioFile::close() { setFileType(kAudioFileNone); BaseAudioFile::setPCMFormat(kAudioFileInt8); setHeaderEndianness(kAudioFileLittleEndian); setAudioEndianness(kAudioFileLittleEndian); setSamplingRate(0); setChannels(0); setFrames(0); setPCMOffset(0); clearErrorFlags(); }
DSP::DSP() { setResampler(ResampleEngine::Hermite); setResamplerFrequency(44100.0); setChannels(2); setPrecision(16); setFrequency(44100.0); setVolume(1.0); setBalance(0.0); clear(); }
// Destructor. qtractorDssiPlugin::~qtractorDssiPlugin (void) { // Cleanup all plugin instances... setChannels(0); // Remove reference from multiple instance pool. if (m_pDssiMulti) dssi_multi_destroy(static_cast<qtractorDssiPluginType *> (type())); // Remove last output control port values seen... if (m_pfControlOutsLast) delete [] m_pfControlOutsLast; }
static void bind(IrcBuffer* buffer, IrcCommandParser* parser) { if (buffer && parser) { IrcBufferModel* model = buffer->model(); QObject::connect(model, SIGNAL(channelsChanged(QStringList)), parser, SLOT(setChannels(QStringList))); QObject::connect(buffer, SIGNAL(titleChanged(QString)), parser, SLOT(setTarget(QString))); parser->setTarget(buffer->title()); parser->setChannels(buffer->model()->channels()); } else if (parser) { parser->reset(); } }
/** * Constructor of JPG Image Class. * It's advised when you want to create * a new JPG File. * NOTE: For default all JPG Files are opened * in colored mode with 8 bits per pixel. */ JPGImage::JPGImage(){ setFilename("NO_FILE"); setSize(0); setWidth(0); setHeight(0); setChannels(0); setImageID(0); setGrayScaleAvaliable(false); setBlackAndWhiteAvaliable(false); setBitsPerPixel(8); }
void Session::initFrom(const ConnectionInfo& connection) { setName(connection.name); setSecure(connection.secure); setPassword(connection.pass); setHost(connection.host); setPort(connection.port); setNickName(connection.nick); QString appName = QApplication::applicationName(); setUserName(connection.user.isEmpty() ? appName : connection.user); setRealName(connection.real.isEmpty() ? appName : connection.real); setChannels(connection.channels); m_quit = connection.quit; }
// Destructor. qtractorLadspaPlugin::~qtractorLadspaPlugin (void) { // Cleanup all plugin instances... setChannels(0); // Free up all the rest... if (m_piAudioOuts) delete [] m_piAudioOuts; if (m_piAudioIns) delete [] m_piAudioIns; if (m_piControlOuts) delete [] m_piControlOuts; if (m_pfControlOuts) delete [] m_pfControlOuts; }
ChannelWidget::ChannelWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ChannelWidget), doubanfm(DoubanFM::getInstance()) { ui->setupUi(this); ui->nextButton->raise(); ui->prevButton->raise(); connect(&doubanfm, SIGNAL(receivedChannels(QList<DoubanChannel>)), this, SLOT(setChannels(QList<DoubanChannel>))); doubanfm.getChannels(); timer = new QTimer(this); connect(timer, &QTimer::timeout, [=] () { qDebug() << "Switch to channel" << channels[ui->slider->currentIndex()].name; emit channelChanged(channels[ui->slider->currentIndex()].channel_id); }); connect(ui->slider, &HorizontalSlider::scrollFinished, [this] () { channel = channels[ui->slider->currentIndex()].channel_id; if (timer && timer->isActive()) timer->stop(); timer->setSingleShot(true); timer->start(2000); }); QSettings settings("QDoubanFM", "QDoubanFM"); settings.beginGroup("General"); channel = settings.value("channel", 1).toInt(); if (!doubanfm.hasLogin() && channel == -3) channel = 1; settings.endGroup(); connect(&doubanfm, &DoubanFM::logoffSucceed, [this] () { if (ui->slider->currentIndex() == 0){ ui->slider->currentObject()->setStyleSheet(DARK_STYLE); ui->slider->scrollToIndex(1); ui->slider->currentObject()->setStyleSheet(HIGHTLIGHT_STYLE); } else { doubanfm.getNewPlayList(channel); } qDebug() << "Logoff successfully. Refreshing playlist"; }); connect(this, SIGNAL(channelChanged(qint32)), &DoubanPlayer::getInstance(), SLOT(setChannel(qint32))); }
int SoundSourceModPlug::parseHeader() { if (m_pModFile == NULL) { // an error occured qDebug() << "Could not parse module header of " << m_qFilename; return ERR; } switch (ModPlug::ModPlug_GetModuleType(m_pModFile)) { case NONE: setType(QString("None")); break; case MOD: setType(QString("Protracker")); break; case S3M: setType(QString("Scream Tracker 3")); break; case XM: setType(QString("FastTracker2")); break; case MED: setType(QString("OctaMed")); break; case IT: setType(QString("Impulse Tracker")); break; case STM: setType(QString("Scream Tracker")); break; case OKT: setType(QString("Oktalyzer")); break; default: setType(QString("Module")); break; } setComment(QString(ModPlug::ModPlug_GetMessage(m_pModFile))); setTitle(QString(ModPlug::ModPlug_GetName(m_pModFile))); setDuration(ModPlug::ModPlug_GetLength(m_pModFile) / 1000); setBitrate(8); // not really, but fill in something... setSampleRate(44100); setChannels(2); return OK; }
Caen785Module::Caen785Module(int _id, QString _name) : BaseModule(_id, _name) , dmx (evslots, this) { setChannels(); createOutputPlugin(); evcntr = 0; status1 = 0; status2 = 0; // Setup conf.base_addr = 0x40000000; // Create user interface setUI (new Caen785UI(this)); std::cout << "Instantiated Caen785Module" << std::endl; }
IrcBot::IrcBot(QObject* parent) : IrcConnection(parent) { //! [messages] connect(this, SIGNAL(privateMessageReceived(IrcPrivateMessage*)), this, SLOT(processMessage(IrcPrivateMessage*))); //! [messages] //! [commands] parser.addCommand(IrcCommand::CtcpAction, "ACT [target] <message...>"); parser.addCommand(IrcCommand::Custom, "HELP (<command...>)"); parser.addCommand(IrcCommand::Nick, "NICK <nick>"); parser.addCommand(IrcCommand::Join, "JOIN <#channel> (<key>)"); parser.addCommand(IrcCommand::Part, "PART (<#channel>) (<message...>)"); parser.addCommand(IrcCommand::Quit, "QUIT (<message...>)"); parser.addCommand(IrcCommand::Message, "SAY [target] <message...>"); //! [commands] bufferModel.setConnection(this); //! [channels] connect(&bufferModel, SIGNAL(channelsChanged(QStringList)), &parser, SLOT(setChannels(QStringList))); //! [channels] }
bool Fixture::loadXML(const QDomElement* root, const QLCFixtureDefCache& fixtureDefCache) { const QLCFixtureDef* fixtureDef = NULL; const QLCFixtureMode* fixtureMode = NULL; QString manufacturer; QString model; QString modeName; QString name; t_fixture_id id = KInvalidFixtureID; t_channel universe = 0; t_channel address = 0; t_channel channels = 0; QDomElement tag; QDomNode node; Q_ASSERT(root != NULL); if (root->tagName() != KXMLFixture) { qDebug() << "Fixture node not found!"; return false; } node = root->firstChild(); while (node.isNull() == false) { tag = node.toElement(); if (tag.tagName() == KXMLQLCFixtureDefManufacturer) { manufacturer = tag.text(); } else if (tag.tagName() == KXMLQLCFixtureDefModel) { model = tag.text(); } else if (tag.tagName() == KXMLQLCFixtureMode) { modeName = tag.text(); } else if (tag.tagName() == KXMLFixtureID) { id = tag.text().toInt(); } else if (tag.tagName() == KXMLFixtureName) { name = tag.text(); } else if (tag.tagName() == KXMLFixtureUniverse) { universe = tag.text().toInt(); } else if (tag.tagName() == KXMLFixtureAddress) { address = tag.text().toInt(); } else if (tag.tagName() == KXMLFixtureChannels) { channels = tag.text().toInt(); } else { qDebug() << "Unknown fixture instance tag:" << tag.tagName(); } node = node.nextSibling(); } /* Find the given fixture definition */ fixtureDef = fixtureDefCache.fixtureDef(manufacturer, model); if (fixtureDef == NULL) { qDebug() << QString("No fixture definition for [%1 - %2]") .arg(manufacturer).arg(model); } else { /* Find the given fixture mode */ fixtureMode = fixtureDef->mode(modeName); if (fixtureMode == NULL) { qDebug() << QString("Fixture mode [%1] for [%2 - %3] " "not found!").arg(modeName) .arg(manufacturer).arg(model); /* Set this also NULL so that a generic dimmer will be created instead as a backup. */ fixtureDef = NULL; } } /* Number of channels */ if (channels <= 0 || channels > KFixtureChannelsMax) { qDebug() << QString("Fixture [%1] channels %2 out of bounds " "(%3 - %4).").arg(name).arg(channels).arg(1) .arg(KFixtureChannelsMax); channels = KFixtureChannelsMax; } /* Make sure that address is something sensible */ if (address > 511 || address + (channels - 1) > 511) { qDebug() << QString("Fixture channel range %1 - %2 out of DMX " "bounds (%3 - %4).").arg(address) .arg(address + channels).arg(0).arg(511); address = 0; } /* Make sure that universe is something sensible */ if (universe >= KUniverseCount) { qDebug() << QString("Fixture universe %1 out of bounds " "(%2 - %3).").arg(universe).arg(0) .arg(KUniverseCount - 1); universe = 0; } /* Check that we have a sensible ID, otherwise we can't continue */ if (id < 0 || id >= KFixtureArraySize) { qDebug() << QString("Fixture ID %1 out of bounds (%2 - %3).") .arg(id).arg(0).arg(KFixtureArraySize - 1); return false; } if (fixtureDef != NULL && fixtureMode != NULL) { /* Assign fixtureDef & mode only if BOTH are not NULL */ setFixtureDefinition(fixtureDef, fixtureMode); } else { /* Otherwise set just the channel count */ setChannels(channels); } setAddress(address); setUniverse(universe); setName(name); return true; }
/*! Sets the list of cell broadcast channels to \a list. The result of performing the operation is returned by the setChanelsResult() signal. \sa setChannelsResult() */ void QCellBroadcast::setChannels( const QList<int>& list ) { invoke( SLOT(setChannels(QList<int>)), qVariantFromValue( list ) ); }
~Buffer() { setChannels(0); }
void setArguments(){ /* * Verification os file in */ if (fileIn == NULL){ fprintf(stderr, "There is no input file.\n"); exit(-1); } /* * Verification o number of bits. * Number default: 1. */ if (nbBits == -1){ nbBits = 1; } else{ if(nbBits>8 || nbBits <1){ fprintf(stderr, "Not possible to pattern a message with this number of bits\n"); exit(-1); } } /* * Verification of pattern * Default pattern: Direct. */ if(pattern == NULL){ pattern = "DIRECT"; patternInt = 1; } else{ flag = validatePattern(); switch (flag){ case -1: fprintf(stderr, "Not a valid pattern\n"); exit(-1); case 1: patternInt = flag; //Direct Pattern break; case 2: patternInt = flag; //Inverse break; case 3: fprintf(stderr, "External spiral pattern not implemented\n"); exit(-3); case 4: fprintf(stderr, "Internal spiral pattern not implemented\n"); exit(-4); } } /** * Setting and validation os Channels * Default: Red,Green,Blue */ if (channels == NULL){ firstChannel = 2; secondChannel = 1; thirdChannel = 0; }else{ setChannels(); } /** * Validation of Magic Number * Default: 48454C50 */ if(magicHexa == NULL){ magicHexa = "48454C50"; magic = hex_to_str(magicHexa); // magic = "HELP" }else{ magic = hex_to_str(magicHexa); } /** * Validation of Output * Default: Standart (Console) */ if(fileOut != NULL){ isStandard = false; } else { isStandard = true; fileOut = "output.txt"; } /** * Validation of the format of input * If there is no format, the program will detect. * If the format of the image its different of the argument or it is not a format accepted, * the program ends/error. */ img = cvLoadImage(fileIn, 1); // Second parameter == 1 (RGB) || == 0 (GREY) if (img){ //Try to load the image by OpenCv if(formatIn == NULL){ int format = detect_format(fileIn); if (format == -1){ fprintf(stderr, "Not possible to detect format\n"); exit(-1); } } else { flag = validateFormat(); switch (flag) { case 0: //Accepted break; case -1: fprintf(stderr, "%s is not a format accepted\n", formatIn); exit(-1); case -2: fprintf(stderr, "This format is not the format of the image\n"); exit(-2); case -3: fprintf(stderr, "Not a format valid\n"); exit(-2); } } }else{ fprintf(stderr, "Could not open the file\n"); exit(-3); } }