Cleaning a mess of code

The envelope editors in HourGlass have been an integral part since the beginning. As time has passed, lots of hacks upon hacks have been added to enable certain things to work. This lead to a situation where the envelope editors have been very tied to other parts of the application. It’s basically not been possible to reuse the envelope editors for things that didn’t involve those other parts, properly initialized, in correct order. I started doing some clean up and managed to get this (click image for animation) :

hg_envelopes_standalone1

This can now happen with relatively little code that doesn’t involve a lot of objects or other stuff initialized. (The formatting gets messed up when pasting here on WordPress, I don’t really write code like that, but the code is an interesting tidbit.)

int main(int argc, char *argv[])
{
QApplication a(argc,argv);
XenEnvNode::initNodeShapeInfos();
QWidget* testWidget=new QWidget;
QGridLayout* glao=new QGridLayout(testWidget);
for (int i=0;i<16;i++) { QString dispName=QString("LOL %1").arg(i); QString internalName=QString("LOLLO%1").arg(i); HGParam* LOLparam=new HGParam(dispName,internalName); LOLparam->addNode(0.0,0.0,Shape_Power);
LOLparam->addNode(1.0,1.0,Shape_Power);
XenEnvelopeWidget* LOLtest=new XenEnvelopeWidget(0,0);
int row=i % 4;
int column=i / 4;
glao->addWidget(LOLtest,row,column,1,1);
LOLtest->switchToParameter(LOLparam);
}
testWidget->show();
a.exec();
return 0;
}

The envelope editor code unfortunately now achieves this with some rather dirty ways. Anyway, it’s a decent start to more or less fully decouple the envelope editors from other
parts of the application. Besides giving me peace of mind, possible use scenarios would be to have the MIDI/OSC remote controls shaping happening with the envelope editors or
making a waveshaping DSP effect that can reuse the envelope editor code cleanly.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

9 Responses to Cleaning a mess of code

  1. Tony says:

    Is it difficult to add .ogg file support into HourGlass?

    • xenakios says:

      Not too hard, at least on Windows. On OS-X I would need to see how to build libsndfile with ogg (and flac) support enabled. It could be a bit difficult…

      • Tony says:

        Yeah, I am also a Windows user, that would be really great. I am sampling usually with HarddiskOgg from all kind of places, YouTube, anything playing out from my sound card, and being able to drop those “samplings” directly into HourGlass would be great, instant fun. Just sample 5 seconds quickly, drop it on HourGlass, have fun. Now I had to sample in .wav just to be able to drop onto HourGlass. Maybe you can consider it in a future version. Thanks for your fantastic HourGlass.

  2. xenakios says:

    On Windows the missing ogg import has mostly been an oversight. The support has already been there, but I forgot to add the .ogg file extension to the relevant places in the code. I don’t think you can yet in the public version fool HourGlass to load ogg files because the file extension check prevents the files from loading at an early stage. I am not completely sure though…I’d need to check the old code what it really did. But perhaps it’s best to wait for the next build which has ogg import explicitly enabled in the file dialogs and drag and drop.

    • Tony says:

      Thanks a lot, I will wait for the next build.

    • Tony says:

      Just tried running HourGlass using the command line as: HourGlass.exe test.wav
      it says “Problem with audio file”. If I drag and drop test.wav on HourGlass it works. Does not HourGlass support running from command line? At least simple, single .wav (or .ogg) files later.

      • xenakios says:

        Yeah the sound viewer seems to display that error message when using the command line with a sound file. The file appears to still work for playback, though. You must click in the sound sources panel on the file cell to make it appear in the sound viewer. I’ll look into fixing that.

      • xenakios says:

        Note that HourGlass goes into a special state when an audio file has been loaded from the command line. Rendering the texture attempts to overwrite the source file, though you will be warned about that by default. There will be no warning when quitting HourGlass about saving the current workspace. These behaviors were done in order to make using HourGlass more convenient as an external editor when called from other apps like Cockos Reaper.

      • Tony says:

        Yes, I immediately thought of it also being external editor for Reaper, very cool. Thanks xenakios, whatever you do is awesome.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s