Beispiel #1
0
void QuickTimeDecoder::init() {
	Audio::QuickTimeAudioDecoder::init();

	// Initialize all the audio tracks
	for (uint32 i = 0; i < _audioTracks.size(); i++)
		addTrack(new AudioTrackHandler(this, _audioTracks[i]));

	// Initialize all the video tracks
	const Common::Array<Common::QuickTimeParser::Track *> &tracks = Common::QuickTimeParser::_tracks;
	for (uint32 i = 0; i < tracks.size(); i++) {
		if (tracks[i]->codecType == CODEC_TYPE_VIDEO) {
			for (uint32 j = 0; j < tracks[i]->sampleDescs.size(); j++)
				((VideoSampleDesc *)tracks[i]->sampleDescs[j])->initCodec();

			addTrack(new VideoTrackHandler(this, tracks[i]));
		}
	}

	// Prepare the first video track
	VideoTrackHandler *nextVideoTrack = (VideoTrackHandler *)findNextVideoTrack();

	if (nextVideoTrack) {
		if (_scaleFactorX != 1 || _scaleFactorY != 1) {
			// We have to take the scale into consideration when setting width/height
			_width = (nextVideoTrack->getScaledWidth() / _scaleFactorX).toInt();
			_height = (nextVideoTrack->getScaledHeight() / _scaleFactorY).toInt();
		} else {
			_width = nextVideoTrack->getWidth();
			_height = nextVideoTrack->getHeight();
		}
	}
}
Beispiel #2
0
bool JukeboxDS::initialize( const char * pFilePath, int volume )
{
	release();

	// build the file list
	m_FilePath = Path( pFilePath ).directory();
	if (! m_FilePath.endsWith(("\\")) )
		m_FilePath += ("\\");
	m_JukeboxConfig = m_FilePath + ("config.ini");

	// load the jukebox configuration if the file exists
	if ( FileDisk::fileExists( m_JukeboxConfig ) )
	{
		Settings config( ("Jukebox"), m_JukeboxConfig );

		int listCount = config.get( ("listCount"), (dword)0 );
		for(int i=0;i<listCount;i++)
		{
			int newList = addPlayList( config.get( CharString().format( ("List%dName"), i ), ("") ) );
			int fileCount = config.get( CharString().format(("List%dFileCount"), i ), (dword)0 );

			for(int j=0;j<fileCount;j++)
				addTrack( newList, config.get( CharString().format(("List%dFile%d"), i, j), ("")) );
		}
	}
	else
	{
		// create a default playlist with all mp3 files in the directory
		addTrack( addPlayList( ("Default") ), m_FilePath + ("*.mp3") );
		// save configuration
		//saveConfig();
	}

	if ( !m_PlayLists.isValid( 0 ) )
		return false;
	if ( !m_PlayLists[ 0 ].files.isValid( 0 ) )
		return false;

	m_ActiveList = 0;
	m_CurrentTrack = 0;

	m_Volume = Clamp( volume, 0, 100 );

	// start the thread
	play();

	return true;
}
void MediaStreamPrivate::addRemoteTrack(MediaStreamTrackPrivate* track)
{
    if (m_client)
        m_client->addRemoteTrack(track);
    else
        addTrack(track);
}
Beispiel #4
0
void K3b::AudioDoc::addTracks( const QList<QUrl>& urls, int position )
{
    QList<QUrl> allUrls = extractUrlList( K3b::convertToLocalUrls(urls) );
    QList<QUrl>::iterator end( allUrls.end());
    for( QList<QUrl>::iterator it = allUrls.begin(); it != end; it++, position++ ) {
        QUrl& url = *it;
        if( url.toLocalFile().right(3).toLower() == "cue" ) {
            // try adding a cue file
            if( K3b::AudioTrack* newAfter = importCueFile( url.toLocalFile(), getTrack(position) ) ) {
                position = newAfter->trackNumber();
                continue;
            }
        }

        if( K3b::AudioTrack* track = createTrack( url ) ) {
            addTrack( track, position );

            K3b::AudioDecoder* dec = static_cast<K3b::AudioFile*>( track->firstSource() )->decoder();
            track->setTitle( dec->metaInfo( K3b::AudioDecoder::META_TITLE ) );
            track->setArtist( dec->metaInfo( K3b::AudioDecoder::META_ARTIST ) );
            track->setSongwriter( dec->metaInfo( K3b::AudioDecoder::META_SONGWRITER ) );
            track->setComposer( dec->metaInfo( K3b::AudioDecoder::META_COMPOSER ) );
            track->setCdTextMessage( dec->metaInfo( K3b::AudioDecoder::META_COMMENT ) );
        }
    }

    emit changed();
}
Beispiel #5
0
void MediaStream::addRemoteTrack(MediaStreamTrackPrivate* privateTrack)
{
    ASSERT(privateTrack);
    if (!active())
        return;

    RefPtr<MediaStreamTrack> track;
    switch (privateTrack->type()) {
    case RealtimeMediaSource::Audio:
        track = AudioStreamTrack::create(*scriptExecutionContext(), *privateTrack);
        break;
    case RealtimeMediaSource::Video:
        track = VideoStreamTrack::create(*scriptExecutionContext(), *privateTrack);
        break;
    case RealtimeMediaSource::None:
        ASSERT_NOT_REACHED();
        break;
    }

    if (!track)
        return;

    if (addTrack(track))
        scheduleDispatchEvent(MediaStreamTrackEvent::create(eventNames().addtrackEvent, false, false, track));
}
Beispiel #6
0
QList<PathItem *> PathView::loadData(const Data &data)
{
	QList<PathItem *> paths;
	int zoom = _zoom;


	for (int i = 0; i < data.tracks().count(); i++)
		paths.append(addTrack(*(data.tracks().at(i))));
	for (int i = 0; i < data.routes().count(); i++)
		paths.append(addRoute(*(data.routes().at(i))));
	addWaypoints(data.waypoints());

	if (_tracks.empty() && _routes.empty() && _waypoints.empty())
		return paths;

	if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
	  || (_waypoints.size() && _zoom < zoom))
		rescale(_zoom);
	else
		updatePOIVisibility();

	QRectF sr = contentsSceneRect();
	_scene->setSceneRect(sr);
	centerOn(sr.center());

	_mapScale->setZoom(_zoom, -(sr.center().ry() * mapScale(_zoom)));
	if (_mapScale->scene() != _scene)
		_scene->addItem(_mapScale);

	return paths;
}
Beispiel #7
0
/** Add a track and set it as current item */
void Playlist::addCurrentTrack( Track* track )
{
    //Add if it comes from outsite only
    bool fromOutsite=true;
    PlaylistItem* currItem = (PlaylistItem*)currentItem();
    if ( currItem )
       if ( track->url() == currItem->track()->url() )
           fromOutsite=false;

    if ( fromOutsite )
        addTrack(track,NULL);
    else
        newPlaylistItem = currItem;


    if (!m_isPlaying){
        //is not playing, direct into player and roll others
        setCurrentPlaylistItem( newPlaylistItem );
    } else {
        //is playing, wait and add as next
        setNextPlaylistItem( newPlaylistItem );
    }

    handleChanges();
}
	void VisualWavesControl::menu_ItemSelected(std::string item)
	{
		assert(visual != NULL);

		hideMenu();
		addTrack(visual->getParameter(item));
	}
MediaStreamPrivate::MediaStreamPrivate(const String& id, const Vector<RefPtr<MediaStreamTrackPrivate>>& audioPrivateTracks, const Vector<RefPtr<MediaStreamTrackPrivate>>& videoPrivateTracks)
    : m_client(0)
    , m_id(id)
    , m_ended(false)
{
    ASSERT(m_id.length());
    for (size_t i = 0; i < audioPrivateTracks.size(); i++)
        addTrack(audioPrivateTracks[i]);

    for (size_t i = 0; i < videoPrivateTracks.size(); i++)
        addTrack(videoPrivateTracks[i]);

    unsigned providedTracksSize = audioPrivateTracks.size() + videoPrivateTracks.size();
    unsigned tracksSize = m_audioPrivateTracks.size() + m_videoPrivateTracks.size();
    // If tracks were provided and no one was added to the MediaStreamPrivate's tracks, this means
    // that the tracks were all ended
    if (providedTracksSize > 0 && !tracksSize)
        m_ended = true;
}
void
Grid::openPredictionGrid(QString fname)
{
    fstream file_ip((fname.toStdString()).c_str(), ios::in);
    if (!file_ip) {
        cerr << "Can't open input file " << endl;
        return;
    }

    int x_size = 0;
    int y_size = 0;
    int index = 0;
    int splitIndex = 0;
    QString qFname = "";
    string intBufferStr = "";
    string line = "";
    string listFname = "";
    string vecIndex = "";

    cout << "doing file stuff" << endl;

    // get the stored size of the vector
    getline(file_ip,intBufferStr);
    istringstream intBuffer(intBufferStr);
    intBuffer >> x_size;

    getline(file_ip, intBufferStr);
    istringstream intBufferTwo(intBufferStr);
    intBufferTwo >> y_size;

    cout << "x_size = " << x_size << endl;
    cout << "y_size = " << y_size << endl;

    cout << "Before reset grid" << endl;
    resetGrid();
    cout << "After reset grid" << endl;

    int i = 1;
    while(!file_ip.eof())
    {
        getline(file_ip,line);
        cout << "Line is " << line << endl;

        splitIndex = line.find_first_of(',');
        vecIndex = line.substr(0,splitIndex);
        listFname = line.substr(splitIndex + 1);
        qFname =  listFname.c_str();
        istringstream buffer(vecIndex);
        buffer >> index;
        cout << "index = " << index << endl;
        cout << "filename = " << qFname << endl;

        addTrack(index % som_height, index / som_height, qFname);
    }
}
Beispiel #11
0
void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
{
    if (!prpTrack) {
        ec = TYPE_MISMATCH_ERR;
        return;
    }

    if (addTrack(prpTrack)) {
        for (auto observer = m_observers.begin(), end = m_observers.end(); observer != end; ++observer)
            (*observer)->didAddOrRemoveTrack();
    }
}
void SpotifySearch::browseFinished()
{
    QSpotifyAlbumBrowse* browse = qobject_cast<QSpotifyAlbumBrowse*>(sender());
    if(browse && !browse->busy())
    {
        qDebug()<<browse->tracks()->count();
        for(int i = 0; i < browse->tracks()->count(); i++)
        {
            addTrack( browse->tracks()->at(i));
        }
    }
}
Beispiel #13
0
void DlgTagFetcher::updateStack() {
    if (m_data.m_pending) {
        stack->setCurrentWidget(loading_page);
        return;
    } else if (m_networkError == HTTPERROR) {
        stack->setCurrentWidget(networkError_page);
        return;
    } else if (m_networkError == FTWERROR) {
        stack->setCurrentWidget(generalnetworkError_page);
        return;
    } else if (m_data.m_results.isEmpty()) {
        stack->setCurrentWidget(error_page);
        return;
    }
    btnApply->setEnabled(true);
    stack->setCurrentWidget(results_page);

    results->clear();

    addDivider(tr("Original tags"), results);
    addTrack(m_track, -1, results);

    addDivider(tr("Suggested tags"), results);

    int trackIndex = 0;
    foreach (const TrackPointer track, m_data.m_results) {
        addTrack(track, trackIndex++, results);
    }

    // Find the item that was selected last time
    for (int i=0 ; i<results->model()->rowCount() ; ++i) {
        const QModelIndex index = results->model()->index(i, 0);
        const QVariant id = index.data(Qt::UserRole);
        if (!id.isNull() && id.toInt() == m_data.m_selectedResult) {
            results->setCurrentIndex(index);
            break;
        }
    }
}
Beispiel #14
0
int MassImport::load(ppluint8 DeviceType, ppluint32 DeviceId, ppluint8 Page, ppluint16 StartTrack)
{

    this->DeviceType=DeviceType;
    this->DeviceId=DeviceId;
    this->Page=Page;
    this->StartTrack=StartTrack;

    TrackList=wm->GetTracklist(DeviceType,DeviceId,Page);


    ppl6::CString Path, Filename, Pattern;
    ppl6::CString MP3Path=wm->conf.DevicePath[DeviceType];

    if (MP3Path.IsEmpty()) return 0;
    Path=MP3Path;
    Path.RTrim("/");
    Path.RTrim("\\");
    Path.Concatf("/%02u/%03u/",(ppluint32)(DeviceId/100),DeviceId);
    Pattern.Setf("*.mp3");
    ppl6::CDir Dir;
    const ppl6::CDirEntry *entry;
    int count=0;
    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    qApp->processEvents();
    ui.treeWidget->setSortingEnabled(false);

    if (Dir.Open(Path,ppl6::CDir::Sort_Filename_IgnoreCase)) {
        if (wmlog) wmlog->Printf(ppl6::LOG::DEBUG,5,"CWMClient","NextMP3File",__FILE__,__LINE__,"%i Dateien vorhanden, suche nach Pattern...",Dir.Num());
        while ((entry=Dir.GetNextPattern(Pattern,true))) {
            Filename=entry->Filename;
            // Der Dateiname darf nicht mit drei Ziffern und Bindestrich beginnen
            if (!Filename.PregMatch("/^[0-9]{3}\\-.*/")) {
                // Muss aber mit .mp3 enden
                if (Filename.PregMatch("/^.*\\.mp3$/i")) {
                    //printf ("%s\n",(const char*)Filename);
                    addTrack(entry->File);
                    count++;
                }
            }
        }
    }
    ui.treeWidget->sortByColumn(0,Qt::AscendingOrder);
    ui.treeWidget->setSortingEnabled(true);
    QApplication::restoreOverrideCursor();
    if (count) return 1;
    QMessageBox::information(this, tr("WinMusik: Notice"),
                             tr("There are no tracks to import"));
    return 0;

}
Beispiel #15
0
bool VideoDecoder::addStreamFileTrack(const Common::String &baseName) {
	// Only allow adding external tracks if a video is already loaded
	if (!isVideoLoaded())
		return false;

	StreamFileAudioTrack *track = new StreamFileAudioTrack();

	bool result = track->loadFromFile(baseName);

	if (result)
		addTrack(track);

	return result;
}
Beispiel #16
0
void Playlist::appendList( const QList<QUrl> urls, PlaylistItem* after )
{
   qDebug() << __FUNCTION__;

   int droppedUrlCnt = urls.size();
   for(int i = droppedUrlCnt-1; i > -1 ; i--) {
       QString localPath = urls[i].toLocalFile();
       QFileInfo fileInfo(localPath);
       if(fileInfo.isFile()) {
           // file
           addTrack( urls[i], after );
       }
       else
           if(fileInfo.isDir()) {
               // directory
               if(fileInfo.isDir()) {
                   // directory
                   QStringList filters;
                   filters << "*.mp3" << "*.ogg" << "*.wav";

                   QDirIterator it(localPath,
                                   filters,
                                   QDir::Files|QDir::NoSymLinks|QDir::NoDotAndDotDot,
                                   QDirIterator::Subdirectories);
                   while(it.hasNext()) {
                       it.next();
                       addTrack("file:///" + it.filePath(), after );
                   }

               }
           }
           else {
         // none
           }
   }
   checkCurrentItem();
}
Beispiel #17
0
TEST_F( DeviceFs, PartialAlbumRemoval )
{
    ml->discover( mock::FileSystemFactory::Root );
    bool discovered = cbMock->waitDiscovery();
    ASSERT_TRUE( discovered );

    {
        auto album = ml->createAlbum( "album" );
        auto media = ml->media( mock::FileSystemFactory::SubFolder + "subfile.mp4" );
        auto media2 = ml->media( RemovableDeviceMountpoint + "removablefile2.mp3" );
        auto newArtist = ml->createArtist( "artist" );
        album->addTrack( std::static_pointer_cast<Media>( media ), 1, 1, newArtist->id(), nullptr );
        album->addTrack( std::static_pointer_cast<Media>( media2 ), 2, 1, newArtist->id(), nullptr );
        album->setAlbumArtist( newArtist );
        newArtist->updateNbTrack( 2 );
        newArtist->addMedia( static_cast<Media&>( *media ) );
        newArtist->addMedia( static_cast<Media&>( *media2 ) );
    }

    auto albums = ml->albums( nullptr )->all();
    ASSERT_EQ( 1u, albums.size() );
    auto artists = ml->artists( true, nullptr )->all();
    ASSERT_EQ( 1u, artists.size() );
    auto artist = artists[0];
    ASSERT_EQ( 2u, artist->tracks( nullptr )->count() );

    auto device = fsMock->removeDevice( RemovableDeviceUuid );
    Reload();

    albums = ml->albums( nullptr )->all();
    ASSERT_EQ( 1u, albums.size() );
    artists = ml->artists( true, nullptr )->all();
    ASSERT_EQ( 1u, artists.size() );
    ASSERT_EQ( 1u, albums[0]->tracks( nullptr )->count() );
    ASSERT_EQ( 1u, artists[0]->tracks( nullptr )->count() );
}
AudioController::AudioController(QObject *parent):
	QObject(parent),
	m_playList()
{
	addTrack("Best_of_Times_Kyle_Gabler");
	addTrack("Atrox_OST-Track_1");
	addTrack("Atrox_OST-Track_2");
	addTrack("Atrox_OST-Track_3");
	addTrack("Atrox_OST-Track_5");
	addTrack("Audiomachine-Devils_Tower");
}
Beispiel #19
0
void EntityManager::createTrack(char* path, btTransform &trans)
{
	btScalar mass = btScalar(0.f);

	Track* trk = new Track();

	trk->initRenderObject(path);

	btCollisionShape* triMesh = sFactory.createStaticTriangleMesh(trk->renderObject);

	trk->initPhysicsObject(triMesh, mass, trans);

	trk->lowestPoint();

	addTrack(trk);

	Physics::Inst()->addEntity(*trk);
}
Beispiel #20
0
bool DXADecoder::loadStream(Common::SeekableReadStream *stream) {
	close();

	uint32 tag = stream->readUint32BE();

	if (tag != MKTAG('D','E','X','A')) {
		close();
		return false;
	}

	DXAVideoTrack *track = new DXAVideoTrack(stream);
	addTrack(track);

	readSoundData(stream);

	track->setFrameStartPos();
	return true;
}
Beispiel #21
0
TrackEditor::TrackEditor(QList<Track> *tracks, QWidget *parent)
    : QDialog(parent)
{
    this->tracks = tracks;
    //视图控件
    tableWidget = new QTableWidget(tracks->count(), 2);
    //设置委托
    tableWidget->setItemDelegate(new TrackDelegate(1));
    //设置视图列头
    tableWidget->setHorizontalHeaderLabels(
            QStringList() << tr("Track") << tr("Duration"));
    //初始化视图内容
    for (int row = 0; row < tracks->count(); ++row) {
        Track track = tracks->at(row);

        QTableWidgetItem *item0 = new QTableWidgetItem(track.title);
        //设置第0列中所有项
        tableWidget->setItem(row, 0, item0);

        QTableWidgetItem *item1
             = new QTableWidgetItem(QString::number(track.duration));
        item1->setTextAlignment(Qt::AlignRight);
        //设置第1列所有项
        tableWidget->setItem(row, 1, item1);
    }
    //根据委托的SizeHint,重新设置视图大小
    tableWidget->resizeColumnToContents(0);

    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
                                     | QDialogButtonBox::Cancel);
    QPushButton *addTrackButton = buttonBox->addButton(tr("&Add Track"),
            QDialogButtonBox::ActionRole);

    connect(addTrackButton, SIGNAL(clicked()), this, SLOT(addTrack()));
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(tableWidget);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("Track Editor"));
}
Beispiel #22
0
void TrackView::read(Xml& xml)/*{{{*/
{
	for (;;)
	{
		Xml::Token token = xml.parse();
		const QString& tag = xml.s1();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return;
			case Xml::TagStart:
				if(tag == "name")
				{
					_name = xml.parse1();
				}
				else if(tag == "comment")
				{
					_comment = xml.parse1();
				}
				else if(tag == "selected")
				{
					_selected = (bool)xml.parseInt();
				}
				else if (tag == "vtrack")
				{
					Track* t = song->findTrack(xml.parse1());
					if (t)
					{
						//printf("TrackView::read() Adding track\n");
						addTrack(t);
					}
				}
				break;
			case Xml::Attribut:
				break;
			case Xml::TagEnd:
				if(tag == "trackview")
					return;
			default:
				break;
		}
	}
}/*}}}*/
void SpotifySearch::resultsChanged()
{
    qDebug() << _search->trackResults()->count()<< " COUNT!!";
    if(_search->trackResults()->count() > 0)
    {

        for(int i = 0; i < _search->trackResults()->count(); i++)
        {
            addTrack(_search->trackResults()->at(i));
        }

        for(int i= 0; i < _search->albums()->count(); i++)
        {
           std::shared_ptr<QSpotifyAlbum> album = _search->albums()->at(i);
           QSpotifyAlbumBrowse* browse =  album->browse();
           connect(browse, SIGNAL(busyChanged()), this, SLOT(browseFinished()));
        }
    }
}
void CTournamentBase::fillTournamentGUI() {
  if (m_bNetClient) return;

  m_pName->setText(m_pTournament?m_pTournament->getName():L"new tournament");

  if (m_pTournament)
    for (u32 i=0; i<m_pTournament->getRaceCount(); i++) {
      CTournamentRaceGUI *pRace=new CTournamentRaceGUI(m_pDevice,m_lRaces.getSize(),m_pRaceTab,!m_bNetClient);
      pRace->setTrack(m_pTournament->getRace(i)->getTrack());
      pRace->setLaps(m_pTournament->getRace(i)->getLaps());
      m_lRaces.push_back(pRace);

      addTrack(i);
      trackChanged(i,stringc(m_pTournament->getRace(i)->getTrack()).c_str());
      lapsChanged(i,m_pTournament->getRace(i)->getLaps());
    }

  m_pRaceListButtons->setRelativePosition(position2di(5,5+m_lRaces.getSize()*25));
  if (m_lRaces.getSize()>=20) m_pRaceListButtons->setVisible(false);
}
Beispiel #25
0
bool CelDecoder::loadStream(Common::SeekableReadStream *stream) {
	close();

	/* uint32 frameSize = */ stream->readUint32LE();
	uint16 frameType = stream->readUint16LE();

	// Check FLC magic number
	if (frameType != 0xAF12) {
		warning("FlicDecoder::loadStream(): attempted to load non-FLC data (type = 0x%04X)", frameType);
		return false;
	}

	uint16 frameCount = stream->readUint16LE();
	uint16 width = stream->readUint16LE();
	uint16 height = stream->readUint16LE();
	uint16 colorDepth = stream->readUint16LE();
	if (colorDepth != 8) {
		warning("FlicDecoder::loadStream(): attempted to load an FLC with a palette of color depth %d. Only 8-bit color palettes are supported", colorDepth);
		return false;
	}

	addTrack(new CelVideoTrack(stream, frameCount, width, height));
	return true;
}
Beispiel #26
0
bool ConvertXml::endElement( const QString&, const QString&,
                                  const QString& qName)
{
	QString Str;
	if (qName == "actual-notes") {
	    stAno = stCha;
	} else if (qName == "alter") {
	    stAlt = stCha;
	} else if (qName == "attributes") {
		// update this bar's attributes
		if (trk) {
			trk->bars()[bar-1].time1=stBts.toInt();
			trk->bars()[bar-1].time2=stBtt.toInt();
			trk->bars()[bar-1].keysig=stFif.toInt();
		}
	} else if (qName == "backup") {
		tStartCur = -1;
		tEndCur -= stDur.toInt() * 120 / iDiv;
	} else if (qName == "beats") {
	    stBts = stCha;
	} else if (qName == "beat-type") {
	    stBtt = stCha;
	} else if (qName == "chord") {
	    stCho = TRUE;
	} else if (qName == "creator") {
	    stCrt = stCha;
	} else if (qName == "divisions") {
	    stDiv = stCha;
		iDiv = stDiv.toInt();
		if (iDiv <= 0) {
			qDebug() << "illegal divisions value: " << stDiv;
		}
	} else if (qName == "dot") {
	    stDts++;
	} else if (qName == "duration") {
	    stDur = stCha;
	} else if (qName == "encoder") {
	    stEnc = stCha;
	} else if (qName == "fifths") {
	    stFif = stCha;
	} else if (qName == "forward") {
		tStartCur = -1;
		tEndCur += stDur.toInt() * 120 / iDiv;
	} else if (qName == "fret") {
	    stFrt = stCha;
	} else if (qName == "identification") {
		song->info["TITLE"]       = stTtl;
		song->info["ARTIST"]      = stCrt;
		song->info["TRANSCRIBER"] = stEnc;
		song->info["COMMENTS"]    = "";
	} else if (qName == "measure") {
		// forward to end of track in case of incomplete last voice
		int td = trk->trackDuration();
		if (tEndCur < td) {
			tEndCur = td;
			x = trk->c.size();
		}
	} else if (qName == "midi-bank") {
	    stPmb = stCha;
	} else if (qName == "midi-channel") {
	    stPmc = stCha;
	} else if (qName == "midi-program") {
	    stPmp = stCha;
	} else if (qName == "normal-notes") {
	    stNno = stCha;
	} else if (qName == "note") {
	    return addNote();
	} else if (qName == "octave") {
	    stOct = stCha;
	} else if (qName == "part") {
	    trk = NULL;
	} else if (qName == "part-name") {
	    stPnm = stCha;
	} else if (qName == "rest") {
	    stRst = TRUE;
	} else if (qName == "score-part") {
	    bool res = addTrack();
	    // re-init score part specific variables
		initStScorePart();
		return res;
	} else if (qName == "score-timewise") {
			reportError("not supported: score-timewise");
			return false;
	} else if (qName == "staff-lines") {
		stPtn = stCha;
		if (trk) {
			int nStr = stPtn.toInt();
			if ((nStr < 1) || (nStr > MAX_STRINGS))
				nStr = MAX_STRINGS;
			trk->string = nStr;
		}
	} else if (qName == "staff-tuning") {
		if (trk) {
			int iPtl = stPtl.toInt();
			int iPto = stPto.toInt();
			// LVIFIX: Check max_strings
			trk->tune[iPtl - 1]
				= accSt.sao2Pitch(stPts, 0 /* LVIFIX */, iPto);
		}
	} else if (qName == "step") {
	    stStp = stCha;
	} else if (qName == "string") {
	    stStr = stCha;
	} else if (qName == "tuning-step") {
	    stPts = stCha;
	} else if (qName == "tuning-octave") {
	    stPto = stCha;
	} else if (qName == "type") {
	    stTyp = stCha;
	} else if (qName == "work-title") {
	    stTtl = stCha;
	// following elements are explicitly ignored, usually because sub-
	// and superelements handle all the work, sometimes because features
	// are not supported by KGuitar and sometimes they are
	// simply not necessary
	} else if (
			   qName == "accidental-mark"	// not supported by KG
			|| qName == "articulations"
			// LVIFIX: add more ...
			|| qName == "work"		// not supported by KG
			|| qName == "work-number"	// not supported by KG
//			|| qName == ""
		  ) {
	} else {
		// LVIFIX: define what to do, e.g. silently ignore unknown
		// elements, or report these as warning
		// for the time being, the last option is chosen
		Str = "skipping <" + qName + ">";
		reportWarning(Str);
	    // ignore
	}
	return TRUE;
}
Beispiel #27
0
void AVIDecoder::handleStreamHeader(uint32 size) {
	AVIStreamHeader sHeader;
	sHeader.size = size;
	sHeader.streamType = _fileStream->readUint32BE();

	if (sHeader.streamType == ID_MIDS || sHeader.streamType == ID_TXTS)
		error("Unhandled MIDI/Text stream");

	sHeader.streamHandler = _fileStream->readUint32BE();
	sHeader.flags = _fileStream->readUint32LE();
	sHeader.priority = _fileStream->readUint16LE();
	sHeader.language = _fileStream->readUint16LE();
	sHeader.initialFrames = _fileStream->readUint32LE();
	sHeader.scale = _fileStream->readUint32LE();
	sHeader.rate = _fileStream->readUint32LE();
	sHeader.start = _fileStream->readUint32LE();
	sHeader.length = _fileStream->readUint32LE();
	sHeader.bufferSize = _fileStream->readUint32LE();
	sHeader.quality = _fileStream->readUint32LE();
	sHeader.sampleSize = _fileStream->readUint32LE();

	_fileStream->skip(sHeader.size - 48); // Skip over the remainder of the chunk (frame)

	if (_fileStream->readUint32BE() != ID_STRF)
		error("Could not find STRF tag");

	uint32 strfSize = _fileStream->readUint32LE();
	uint32 startPos = _fileStream->pos();

	if (sHeader.streamType == ID_VIDS) {
		if (_frameRateOverride != 0) {
			sHeader.rate = _frameRateOverride.getNumerator();
			sHeader.scale = _frameRateOverride.getDenominator();
		}

		BitmapInfoHeader bmInfo;
		bmInfo.size = _fileStream->readUint32LE();
		bmInfo.width = _fileStream->readUint32LE();
		bmInfo.height = _fileStream->readUint32LE();
		bmInfo.planes = _fileStream->readUint16LE();
		bmInfo.bitCount = _fileStream->readUint16LE();
		bmInfo.compression = _fileStream->readUint32BE();
		bmInfo.sizeImage = _fileStream->readUint32LE();
		bmInfo.xPelsPerMeter = _fileStream->readUint32LE();
		bmInfo.yPelsPerMeter = _fileStream->readUint32LE();
		bmInfo.clrUsed = _fileStream->readUint32LE();
		bmInfo.clrImportant = _fileStream->readUint32LE();

		if (bmInfo.clrUsed == 0)
			bmInfo.clrUsed = 256;

		if (sHeader.streamHandler == 0)
			sHeader.streamHandler = bmInfo.compression;

		byte *initialPalette = 0;

		if (bmInfo.bitCount == 8) {
			initialPalette = new byte[256 * 3];
			memset(initialPalette, 0, 256 * 3);

			byte *palette = initialPalette;
			for (uint32 i = 0; i < bmInfo.clrUsed; i++) {
				palette[i * 3 + 2] = _fileStream->readByte();
				palette[i * 3 + 1] = _fileStream->readByte();
				palette[i * 3] = _fileStream->readByte();
				_fileStream->readByte();
			}
		}

		addTrack(new AVIVideoTrack(_header.totalFrames, sHeader, bmInfo, initialPalette));
	} else if (sHeader.streamType == ID_AUDS) {
		PCMWaveFormat wvInfo;
		wvInfo.tag = _fileStream->readUint16LE();
		wvInfo.channels = _fileStream->readUint16LE();
		wvInfo.samplesPerSec = _fileStream->readUint32LE();
		wvInfo.avgBytesPerSec = _fileStream->readUint32LE();
		wvInfo.blockAlign = _fileStream->readUint16LE();
		wvInfo.size = _fileStream->readUint16LE();

		// AVI seems to treat the sampleSize as including the second
		// channel as well, so divide for our sake.
		if (wvInfo.channels == 2)
			sHeader.sampleSize /= 2;

		addTrack(new AVIAudioTrack(sHeader, wvInfo, _soundType));
	}

	// Ensure that we're at the end of the chunk
	_fileStream->seek(startPos + strfSize);
}
Beispiel #28
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    m_iMeasures     = 100;
    m_bDialogOpen   = false;
    m_bModified     = false;
    m_sCurrentPath  = "";
    m_sCategoryPath = "";
    m_pUndoStack    = new QUndoStack(this);

    ui->setupUi(this);

    addAction( ui->actionNew );
    addAction( ui->actionOpen );
    addAction( ui->actionSave );
    addAction( ui->actionSave_As );
    addAction( ui->actionImport );
    addAction( ui->actionExport );
    addAction( ui->quit );
    addAction( ui->actionUndo );
    addAction( ui->actionRedo );
    addAction( ui->actionCopy_Clip );
    addAction( ui->actionPaste_Clip );
    addAction( ui->actionAdd_Track );

    connect( ui->menuFile, SIGNAL( aboutToShow() ), SLOT( on_menu_aboutToShow() ) );
    connect( ui->menuEdit, SIGNAL( aboutToShow() ), SLOT( on_menu_aboutToShow() ) );

    m_pScene = new QGraphicsScene( this );
    ui->graphicsView->setScene( m_pScene );

    m_pTimeline = new TimelineItem();
    m_pScene->addItem( m_pTimeline );

    // Get settings
    bool initOpenFailed = true;
    QSettings settings("jeremyabel.com", "Prism");
    if ( settings.status() == QSettings::NoError )
    {
        if ( settings.contains("path") )
        {
            m_pCategoryData = new CategoryData();
            m_pImageData    = new ImageData();
            m_sCurrentPath  = settings.value("path").toString();
            qDebug() << " Current path:" << m_sCurrentPath;

            // Attempt to load last file
            QList<TrackModel*> loadedTracks;
            if ( FileManager::open( m_sCurrentPath, &loadedTracks, m_pCategoryData, m_pImageData ) )
            {
                initOpenFailed = false;

                // Add track items
                for ( int i = 0; i < loadedTracks.size(); i++ )
                    addTrack( loadedTracks[i] );

                m_bModified = false;

                ui->statusBar->showMessage("Loaded " + QString::number(loadedTracks.size()) + " track(s) " + "from " + m_sCurrentPath + ".", 10000 );
            }
            else
            {
                // Reset saved path if we have a problem opening this one
                qDebug() << "Previous file could not be opened... resetting.";
                settings.setValue("path", "");
            }
        }
    }

    // Start with new document if we can't open the old one
    if ( initOpenFailed )
    {
        qDebug() << "No previous file found...";

        m_pCategoryData = new CategoryData();
        m_pImageData    = new ImageData();

        // Add one new track
        TrackModel* pTrackModel = new TrackModel( "track 1", QColor(Qt::red) );
        addTrack( pTrackModel );

        ui->statusBar->showMessage("");
    }

    on_timeZoomSlider_valueChanged( 500 );
}
Beispiel #29
0
bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
	close();

	_fileStream = stream;

	// Read in the Smacker header
	_header.signature = _fileStream->readUint32BE();

	if (_header.signature != MKTAG('S', 'M', 'K', '2') && _header.signature != MKTAG('S', 'M', 'K', '4'))
		return false;

	uint32 width = _fileStream->readUint32LE();
	uint32 height = _fileStream->readUint32LE();
	uint32 frameCount = _fileStream->readUint32LE();
	int32 frameDelay = _fileStream->readSint32LE();

	// frame rate contains 2 digits after the comma, so 1497 is actually 14.97 fps
	Common::Rational frameRate;
	if (frameDelay > 0)
		frameRate = Common::Rational(1000, frameDelay);
	else if (frameDelay < 0)
		frameRate = Common::Rational(100000, -frameDelay);
	else
		frameRate = 1000;

	// Flags are determined by which bit is set, which can be one of the following:
	// 0 - set to 1 if file contains a ring frame.
	// 1 - set to 1 if file is Y-interlaced
	// 2 - set to 1 if file is Y-doubled
	// If bits 1 or 2 are set, the frame should be scaled to twice its height
	// before it is displayed.
	_header.flags = _fileStream->readUint32LE();

	SmackerVideoTrack *videoTrack = createVideoTrack(width, height, frameCount, frameRate, _header.flags, _header.signature);
	addTrack(videoTrack);

	// TODO: should we do any extra processing for Smacker files with ring frames?

	// TODO: should we do any extra processing for Y-doubled videos? Are they the
	// same as Y-interlaced videos?

	uint32 i;
	for (i = 0; i < 7; ++i)
		_header.audioSize[i] = _fileStream->readUint32LE();

	_header.treesSize = _fileStream->readUint32LE();
	_header.mMapSize = _fileStream->readUint32LE();
	_header.mClrSize = _fileStream->readUint32LE();
	_header.fullSize = _fileStream->readUint32LE();
	_header.typeSize = _fileStream->readUint32LE();

	for (i = 0; i < 7; ++i) {
		// AudioRate - Frequency and format information for each sound track, up to 7 audio tracks.
		// The 32 constituent bits have the following meaning:
		// * bit 31 - indicates Huffman + DPCM compression
		// * bit 30 - indicates that audio data is present for this track
		// * bit 29 - 1 = 16-bit audio; 0 = 8-bit audio
		// * bit 28 - 1 = stereo audio; 0 = mono audio
		// * bit 27 - indicates Bink RDFT compression
		// * bit 26 - indicates Bink DCT compression
		// * bits 25-24 - unused
		// * bits 23-0 - audio sample rate
		uint32 audioInfo = _fileStream->readUint32LE();
		_header.audioInfo[i].hasAudio = audioInfo & 0x40000000;
		_header.audioInfo[i].is16Bits = audioInfo & 0x20000000;
		_header.audioInfo[i].isStereo = audioInfo & 0x10000000;
		_header.audioInfo[i].sampleRate = audioInfo & 0xFFFFFF;

		if (audioInfo & 0x8000000)
			_header.audioInfo[i].compression = kCompressionRDFT;
		else if (audioInfo & 0x4000000)
			_header.audioInfo[i].compression = kCompressionDCT;
		else if (audioInfo & 0x80000000)
			_header.audioInfo[i].compression = kCompressionDPCM;
		else
			_header.audioInfo[i].compression = kCompressionNone;

		if (_header.audioInfo[i].hasAudio) {
			if (_header.audioInfo[i].compression == kCompressionRDFT || _header.audioInfo[i].compression == kCompressionDCT)
				warning("Unhandled Smacker v2 audio compression");

			if (i == 0)
				addTrack(new SmackerAudioTrack(_header.audioInfo[i], _soundType));
		}
	}

	_header.dummy = _fileStream->readUint32LE();

	_frameSizes = new uint32[frameCount];
	for (i = 0; i < frameCount; ++i)
		_frameSizes[i] = _fileStream->readUint32LE();

	_frameTypes = new byte[frameCount];
	for (i = 0; i < frameCount; ++i)
		_frameTypes[i] = _fileStream->readByte();

	byte *huffmanTrees = (byte *) malloc(_header.treesSize);
	_fileStream->read(huffmanTrees, _header.treesSize);

	Common::BitStream8LSB bs(new Common::MemoryReadStream(huffmanTrees, _header.treesSize, DisposeAfterUse::YES), true);
	videoTrack->readTrees(bs, _header.mMapSize, _header.mClrSize, _header.fullSize, _header.typeSize);

	_firstFrameStart = _fileStream->pos();

	return true;
}
Beispiel #30
0
void Playlist::load()
{
    m_bLoadingState = true;
    int lastIndex = 0;

    setModelHeaders();

    QString fName = m_Settings->appPath();
    fName += QString::number(m_Hash);

    if(QFile::exists(fName)) {
        QSettings sfile(fName, QSettings::IniFormat);

        // Playlist data: library id/name, etc.
        sfile.beginGroup("Playlist");

        switch(m_listType) {
            case PlaylistWidget::Search:
                m_sSearch = sfile.value("strSearch").toString();

                m_Parser->setSearchStr(m_sSearch);
                m_Parser->setOffset(sfile.value("offset").toInt());
                m_Parser->setMore(sfile.value("more").toBool());
                m_Parser->setReqType(0);

                m_listWidget->setSearchStr(m_sSearch);
            break;
            case PlaylistWidget::AudioLib:
            setLibId(sfile.value("libraryId").toString(), "0");
                m_LibraryName = sfile.value("libraryName").toString();
                m_listWidget->setLibraryName(m_LibraryName);

                m_Parser->setReqType(1);
            break;
            case PlaylistWidget::Suggestions:
                m_Parser->setOffset(sfile.value("offset").toInt());
                m_Parser->setMore(sfile.value("more").toBool());
                m_Parser->setReqType(2);
            break;
            case PlaylistWidget::DbSearch:
                m_sSearch = sfile.value("strSearch").toString();

                m_listWidget->setSearchStr(m_sSearch);
            break;
        }
        lastIndex = sfile.value("last_track").toInt();

        sfile.endGroup();

        // Tracks data
        int size = sfile.beginReadArray("Tracks");
        for(int i = 0; i < size; i++) {
            sfile.setArrayIndex(i);

            Track *t = new Track(this);

            t->setArtist(sfile.value("artist").toString());
            t->setTitle(sfile.value("title").toString());
            t->setAlbum(sfile.value("album").toString());
            t->setUrl(sfile.value("url").toString());
            t->setDuration(sfile.value("duration").toString());
            t->setLenght(sfile.value("lenght").toInt());
            t->setAid(sfile.value("aid").toString());
            t->setOid(sfile.value("oid").toString());
            t->setHash(sfile.value("hash").toString());
            t->setDelHash(sfile.value("delHash").toString());
            t->setBitrate(sfile.value("bitrate").toInt());
            t->setMetaArtist(sfile.value("metaArtist").toString());
            t->setMetaTitle(sfile.value("metaTitle").toString());
            t->setMetaAlbum(sfile.value("metaAlbum").toString());
            t->setMetaLoaded(sfile.value("meta").toBool());

            addTrack(t);
            connect(t, SIGNAL(removeMe()), SLOT(onTrackSelfRemove()));

        }

        //fixme
        if(lastIndex < 0)
            lastIndex = 0;

        if(!m_tList.isEmpty()) {
            if(m_tList.size() > 0 && m_tList.size() >= lastIndex)
                m_LastTrack = m_tList.at(lastIndex);
            else
                m_LastTrack = m_tList.first();
        } else {
            m_LastTrack = 0;
        }

            sfile.endArray();
    }

    m_bLoadingState = false;

    m_listWidget->setActiveIndex(m_ProxyModel->index(lastIndex, 0));

}