Add an option to change the quality (texture resolution) of visualisations

This commit is contained in:
David Sansome 2010-06-06 23:05:11 +00:00
parent 93cb686f08
commit 87ecc89ca2
30 changed files with 342 additions and 3 deletions

View File

@ -907,3 +907,13 @@ void projectM::changePresetName ( unsigned int index, std::string name ) {
}
void projectM::changeTextureSize(int size) {
_settings.textureSize = size;
delete renderer;
renderer = new Renderer(_settings.windowWidth, _settings.windowHeight,
_settings.meshX, _settings.meshY,
_settings.textureSize, beatDetect, _settings.presetURL,
_settings.titleFontURL, _settings.menuFontURL);
}

View File

@ -153,7 +153,7 @@ public:
virtual ~projectM();
void changeTextureSize(int size);
const Settings & settings() const {

View File

@ -1230,6 +1230,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1236,6 +1236,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1239,6 +1239,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1239,6 +1239,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1240,6 +1240,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1234,6 +1234,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1246,6 +1246,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1230,6 +1230,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1244,6 +1244,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1232,6 +1232,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1243,6 +1243,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1232,6 +1232,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1236,6 +1236,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1230,6 +1230,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1234,6 +1234,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1237,6 +1237,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1230,6 +1230,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1231,6 +1231,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1237,6 +1237,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1238,6 +1238,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1239,6 +1239,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1230,6 +1230,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1221,6 +1221,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -1230,6 +1230,18 @@ msgstr ""
msgid "Super high (60 fps)"
msgstr ""
msgid "Quality"
msgstr ""
msgid "Low (256x256)"
msgstr ""
msgid "Medium (512x512)"
msgstr ""
msgid "High (1024x1024)"
msgstr ""
msgid "Close visualisation"
msgstr ""

View File

@ -28,7 +28,8 @@
ProjectMVisualisation::ProjectMVisualisation(QObject *parent)
: QGraphicsScene(parent),
projectm_(NULL)
projectm_(NULL),
texture_size_(512)
{
connect(this, SIGNAL(sceneRectChanged(QRectF)), SLOT(SceneRectChanged(QRectF)));
}
@ -41,6 +42,7 @@ void ProjectMVisualisation::drawBackground(QPainter* p, const QRectF&) {
if (!projectm_) {
projectm_.reset(new projectM("/usr/share/projectM/config.inp"));
projectm_->changeTextureSize(texture_size_);
}
projectm_->projectM_resetGL(sceneRect().width(), sceneRect().height());
@ -54,6 +56,13 @@ void ProjectMVisualisation::SceneRectChanged(const QRectF &rect) {
projectm_->projectM_resetGL(rect.width(), rect.height());
}
void ProjectMVisualisation::SetTextureSize(int size) {
texture_size_ = size;
if (projectm_)
projectm_->changeTextureSize(texture_size_);
}
void ProjectMVisualisation::ConsumeBuffer(GstBuffer *buffer, GstEnginePipeline*) {
const int samples_per_channel = GST_BUFFER_SIZE(buffer) / sizeof(short) / 2;
const short* data = reinterpret_cast<short*>(GST_BUFFER_DATA(buffer));

View File

@ -35,6 +35,9 @@ public:
// BufferConsumer
void ConsumeBuffer(GstBuffer *buffer, GstEnginePipeline*);
public slots:
void SetTextureSize(int size);
protected:
// QGraphicsScene
void drawBackground(QPainter *painter, const QRectF &rect);
@ -44,6 +47,8 @@ private slots:
private:
boost::scoped_ptr<projectM> projectm_;
int texture_size_;
};
#endif // PROJECTMVISUALISATION_H

View File

@ -34,6 +34,7 @@ const char* VisualisationContainer::kSettingsGroup = "Visualisations";
const int VisualisationContainer::kDefaultWidth = 828;
const int VisualisationContainer::kDefaultHeight = 512;
const int VisualisationContainer::kDefaultFps = 35;
const int VisualisationContainer::kDefaultTextureSize = 512;
VisualisationContainer::VisualisationContainer(QWidget *parent)
: QGraphicsView(parent),
@ -41,7 +42,8 @@ VisualisationContainer::VisualisationContainer(QWidget *parent)
vis_(new ProjectMVisualisation(this)),
overlay_(new VisualisationOverlay),
menu_(new QMenu(this)),
fps_(kDefaultFps)
fps_(kDefaultFps),
size_(kDefaultTextureSize)
{
setWindowTitle(tr("Clementine Visualisation"));
@ -66,8 +68,10 @@ VisualisationContainer::VisualisationContainer(QWidget *parent)
resize(kDefaultWidth, kDefaultHeight);
}
fps_ = s.value("fps", kDefaultFps).toInt();
size_ = s.value("size", kDefaultTextureSize).toInt();
SizeChanged();
vis_->SetTextureSize(size_);
// Settings menu
menu_->addAction(IconLoader::Load("view-fullscreen"), tr("Toggle fullscreen"),
@ -83,6 +87,15 @@ VisualisationContainer::VisualisationContainer(QWidget *parent)
fps_menu->addActions(fps_group->actions());
connect(fps_mapper, SIGNAL(mapped(int)), SLOT(SetFps(int)));
QMenu* quality_menu = menu_->addMenu(tr("Quality"));
QSignalMapper* quality_mapper = new QSignalMapper(this);
QActionGroup* quality_group = new QActionGroup(this);
AddMenuItem(tr("Low (256x256)"), 256, size_, quality_group, quality_mapper);
AddMenuItem(tr("Medium (512x512)"), 512, size_, quality_group, quality_mapper);
AddMenuItem(tr("High (1024x1024)"), 1024, size_, quality_group, quality_mapper);
quality_menu->addActions(quality_group->actions());
connect(quality_mapper, SIGNAL(mapped(int)), SLOT(SetQuality(int)));
menu_->addSeparator();
menu_->addAction(IconLoader::Load("application-exit"), tr("Close visualisation"),
this, SLOT(hide()));
@ -224,3 +237,14 @@ void VisualisationContainer::SetFps(int fps) {
void VisualisationContainer::ShowPopupMenu(const QPoint &pos) {
menu_->popup(mapToGlobal(pos));
}
void VisualisationContainer::SetQuality(int size) {
size_ = size;
// Save settings
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("size", size_);
vis_->SetTextureSize(size_);
}

View File

@ -40,6 +40,7 @@ public:
static const int kDefaultWidth;
static const int kDefaultHeight;
static const int kDefaultFps;
static const int kDefaultTextureSize;
void SetEngine(GstEngine* engine);
void SetActions(QAction* previous, QAction* play_pause,
@ -72,6 +73,7 @@ private slots:
void ShowPopupMenu(const QPoint& pos);
void ToggleFullscreen();
void SetFps(int fps);
void SetQuality(int size);
private:
GstEngine* engine_;
@ -84,6 +86,7 @@ private:
QMenu* menu_;
int fps_;
int size_;
};
#endif // VISUALISATIONCONTAINER_H