FlpImport: changed most printf()s to qDebug()s and qWarning()s

This improves structure of messages when importing FLP files.
(cherry picked from commit 20eda9a756)
This commit is contained in:
Tobias Doerffel
2009-08-09 11:07:18 +02:00
parent e714a68fe5
commit 9a4cfedf67

View File

@@ -104,9 +104,9 @@ static void dump_mem( const void * buffer, uint n_bytes )
uchar * cp = (uchar *) buffer;
for( uint k = 0; k < n_bytes; ++k )
{
printf( "%02x ", (unsigned int)cp[k] );//( cp[k] > 31 || cp[k] < 7 ) ? cp[k] : '.' );
qDebug( "%02x ", (unsigned int)cp[k] );//( cp[k] > 31 || cp[k] < 7 ) ? cp[k] : '.' );
}
printf( "\n" );
qDebug( "\n" );
}
@@ -585,6 +585,8 @@ flpImport::~flpImport()
}
bool flpImport::tryImport( trackContainer * _tc )
{
const int mappedFilter[] =
@@ -675,21 +677,21 @@ bool flpImport::tryImport( trackContainer * _tc )
if( readID() != makeID( 'F', 'L', 'h', 'd' ) )
{
printf( "flpImport::tryImport(): not a valid FL project\n" );
qWarning( "flpImport::tryImport(): not a valid FL project\n" );
return false;
}
const int header_len = read32LE();
if( header_len != 6 )
{
printf( "flpImport::tryImport(): invalid file format\n" );
qWarning( "flpImport::tryImport(): invalid file format\n" );
return false;
}
const int type = read16LE();
if( type != 0 )
{
printf( "flpImport::tryImport(): type %d format is not "
qWarning( "flpImport::tryImport(): type %d format is not "
"supported\n", type );
return false;
}
@@ -697,7 +699,7 @@ bool flpImport::tryImport( trackContainer * _tc )
p.numChannels = read16LE();
if( p.numChannels < 1 || p.numChannels > 1000 )
{
printf( "flpImport::tryImport(): invalid number of channels "
qWarning( "flpImport::tryImport(): invalid number of channels "
"(%d)\n", p.numChannels );
return false;
}
@@ -705,7 +707,7 @@ bool flpImport::tryImport( trackContainer * _tc )
const int ppq = read16LE();
if( ppq < 0 )
{
printf( "flpImport::tryImport(): invalid ppq\n" );
qWarning( "flpImport::tryImport(): invalid ppq\n" );
return false;
}
@@ -724,14 +726,14 @@ bool flpImport::tryImport( trackContainer * _tc )
const int len = read32LE();
if( file().atEnd() )
{
printf( "flpImport::tryImport(): unexpected "
"end of file\n" );
qWarning( "flpImport::tryImport(): unexpected "
"end of file\n" );
return false;
}
if( len < 0 || len >= 0x10000000 )
{
printf( "flpImport::tryImport(): invalid "
"chunk length %d\n", len );
qWarning( "flpImport::tryImport(): invalid "
"chunk length %d\n", len );
return false;
}
if( id == makeID( 'F', 'L', 'd', 't' ) )
@@ -752,7 +754,7 @@ bool flpImport::tryImport( trackContainer * _tc )
p.channels += FL_Channel();
}
printf( "channels: %d\n", p.numChannels );
qDebug( "channels: %d\n", p.numChannels );
char * text = NULL;
@@ -797,8 +799,8 @@ bool flpImport::tryImport( trackContainer * _tc )
text = new char[text_len+1];
if( readBlock( text, text_len ) <= 0 )
{
printf( "could not read string (len: %d)\n",
text_len );
qWarning( "could not read string (len: %d)\n",
text_len );
}
text[text_len] = 0;
@@ -814,32 +816,32 @@ bool flpImport::tryImport( trackContainer * _tc )
{
// BYTE EVENTS
case FLP_Byte:
printf( "undefined byte %d\n", data );
qDebug( "undefined byte %d\n", data );
break;
case FLP_NoteOn:
printf( "note on: %d\n", data );
qDebug( "note on: %d\n", data );
// data = pos how to handle?
break;
case FLP_Vol:
printf( "vol %d\n", data );
qDebug( "vol %d\n", data );
break;
case FLP_Pan:
printf( "pan %d\n", data );
qDebug( "pan %d\n", data );
break;
case FLP_LoopActive:
printf( "active loop: %d\n", data );
qDebug( "active loop: %d\n", data );
break;
case FLP_ShowInfo:
printf( "show info: %d\n", data );
qDebug( "show info: %d\n", data );
break;
case FLP_Shuffle:
printf( "shuffle: %d\n", data );
qDebug( "shuffle: %d\n", data );
break;
case FLP_MainVol:
@@ -847,11 +849,11 @@ bool flpImport::tryImport( trackContainer * _tc )
break;
case FLP_PatLength:
printf( "pattern length: %d\n", data );
qDebug( "pattern length: %d\n", data );
break;
case FLP_BlockLength:
printf( "block length: %d\n", data );
qDebug( "block length: %d\n", data );
break;
case FLP_UseLoopPoints:
@@ -859,11 +861,11 @@ bool flpImport::tryImport( trackContainer * _tc )
break;
case FLP_LoopType:
printf( "loop type: %d\n", data );
qDebug( "loop type: %d\n", data );
break;
case FLP_ChanType:
printf( "channel type: %d\n", data );
qDebug( "channel type: %d\n", data );
if( cc )
{
switch( data )
@@ -894,7 +896,7 @@ if( p.currentEffectChannel <= NumFxChannels )
// WORD EVENTS
case FLP_NewChan:
cur_channel = data;
printf( "new channel: %d\n", data );
qDebug( "new channel: %d\n", data );
break;
case FLP_NewPat:
@@ -914,7 +916,7 @@ if( p.currentEffectChannel <= NumFxChannels )
break;
case FLP_FX:
printf( "FX: %d\n", data );
qDebug( "FX: %d\n", data );
break;
case FLP_Fade_Stereo:
@@ -926,11 +928,11 @@ if( p.currentEffectChannel <= NumFxChannels )
{
cc->sampleReverseStereo = true;
}
printf( "fade stereo: %d\n", data );
qDebug( "fade stereo: %d\n", data );
break;
case FLP_CutOff:
printf( "cutoff (sample): %d\n", data );
qDebug( "cutoff (sample): %d\n", data );
break;
case FLP_PreAmp:
@@ -938,11 +940,11 @@ if( p.currentEffectChannel <= NumFxChannels )
break;
case FLP_Decay:
printf( "decay (sample): %d\n", data );
qDebug( "decay (sample): %d\n", data );
break;
case FLP_Attack:
printf( "attack (sample): %d\n", data );
qDebug( "attack (sample): %d\n", data );
break;
case FLP_MainPitch:
@@ -950,23 +952,23 @@ if( p.currentEffectChannel <= NumFxChannels )
break;
case FLP_Resonance:
printf( "reso (sample): %d\n", data );
qDebug( "reso (sample): %d\n", data );
break;
case FLP_LoopBar:
printf( "loop bar: %d\n", data );
qDebug( "loop bar: %d\n", data );
break;
case FLP_StDel:
printf( "stdel (delay?): %d\n", data );
qDebug( "stdel (delay?): %d\n", data );
break;
case FLP_FX3:
printf( "FX 3: %d\n", data );
qDebug( "FX 3: %d\n", data );
break;
case FLP_ShiftDelay:
printf( "shift delay: %d\n", data );
qDebug( "shift delay: %d\n", data );
break;
case FLP_Dot:
@@ -998,11 +1000,11 @@ if( p.currentEffectChannel <= NumFxChannels )
}
case FLP_FXSine:
printf( "fx sine: %d\n", data );
qDebug( "fx sine: %d\n", data );
break;
case FLP_CutCutBy:
printf( "cut cut by: %d\n", data );
qDebug( "cut cut by: %d\n", data );
break;
case FLP_MiddleNote:
@@ -1010,15 +1012,15 @@ if( p.currentEffectChannel <= NumFxChannels )
break;
case FLP_DelayReso:
printf( "delay resonance: %d\n", data );
qDebug( "delay resonance: %d\n", data );
break;
case FLP_Reverb:
printf( "reverb (sample): %d\n", data );
qDebug( "reverb (sample): %d\n", data );
break;
case FLP_IntStretch:
printf( "int stretch (sample): %d\n", data );
qDebug( "int stretch (sample): %d\n", data );
break;
// TEXT EVENTS
@@ -1081,7 +1083,7 @@ if( p.currentEffectChannel <= NumFxChannels )
case FLP_Text_Version:
{
printf( "FLP version: %s\n", text );
qDebug( "FLP version: %s\n", text );
p.versionString = text;
QStringList l = p.versionString.split( '.' );
p.version = ( l[0].toInt() << 8 ) +
@@ -1102,36 +1104,32 @@ if( p.currentEffectChannel <= NumFxChannels )
mappedPluginTypes[QString( text ).toLower()] );
if( t > FL_Plugin::EffectPlugin )
{
printf( "recognized new "
"effect %s\n", text );
p.effects.push_back(
FL_Effect( t ) );
qDebug( "recognized new effect %s\n", text );
p.effects.push_back( FL_Effect( t ) );
}
else if( cc )
{
printf( "recognized new "
"plugin %s\n", text );
qDebug( "recognized new plugin %s\n", text );
cc->pluginType = t;
}
last_plugin_type = t;
}
else
{
printf( "unsupported plugin: %s!\n",
text );
qDebug( "unsupported plugin: %s!\n", text );
}
break;
case FLP_Text_EffectChanName:
++p.currentEffectChannel;
if( p.currentEffectChannel <= NumFxChannels )
{
p.effectChannels[p.currentEffectChannel].name = text;
}
++p.currentEffectChannel;
if( p.currentEffectChannel <= NumFxChannels )
{
p.effectChannels[p.currentEffectChannel].name = text;
}
break;
case FLP_Text_Delay:
printf( "delay data: " );
qDebug( "delay data: " );
// pi[1] seems to be volume or similiar and
// needs to be divided
// by p.versionSpecificFactor
@@ -1139,30 +1137,27 @@ if( p.currentEffectChannel <= NumFxChannels )
break;
case FLP_Text_TS404Params:
if( cc && cc->pluginType ==
FL_Plugin::UnknownPlugin &&
if( cc && cc->pluginType == FL_Plugin::UnknownPlugin &&
cc->pluginSettings == NULL )
{
cc->pluginSettings = new char[text_len];
memcpy( cc->pluginSettings, text,
text_len );
memcpy( cc->pluginSettings, text, text_len );
cc->pluginSettingsLength = text_len;
cc->pluginType =
FL_Plugin::TS404;
cc->pluginType = FL_Plugin::TS404;
}
break;
case FLP_Text_NewPlugin:
if( last_plugin_type > FL_Plugin::EffectPlugin )
{
FL_Effect * e = &p.effects.last();
e->fxChannel = puc[0];
e->fxPos = puc[4];
printf( "new effect: " );
FL_Effect * e = &p.effects.last();
e->fxChannel = puc[0];
e->fxPos = puc[4];
qDebug( "new effect: " );
}
else
{
printf( "new plugin: " );
qDebug( "new plugin: " );
}
dump_mem( text, text_len );
break;
@@ -1175,7 +1170,7 @@ if( p.currentEffectChannel <= NumFxChannels )
text_len );
cc->pluginSettingsLength = text_len;
}
printf( "plugin params: " );
qDebug( "plugin params: " );
dump_mem( text, text_len );
break;
@@ -1193,7 +1188,7 @@ if( p.currentEffectChannel <= NumFxChannels )
cc->arpGate = ( pi[14] * 100.0f ) / 48.0f;
cc->arpEnabled = pi[10] > 0;
printf( "channel params: " );
qDebug( "channel params: " );
dump_mem( text, text_len );
break;
@@ -1234,7 +1229,7 @@ if( p.currentEffectChannel <= NumFxChannels )
// e.lfoAmount = pi[11] / 128.0f;
cc->envelopes.push_back( e );
printf( "envelope and lfo params:\n" );
qDebug( "envelope and lfo params:\n" );
dump_mem( text, text_len );
break;
@@ -1255,7 +1250,7 @@ if( p.currentEffectChannel <= NumFxChannels )
cc->filterCut *= 0.5f;
}
}
printf( "basic chan params: " );
qDebug( "basic chan params: " );
dump_mem( text, text_len );
break;
@@ -1268,7 +1263,7 @@ if( p.currentEffectChannel <= NumFxChannels )
{
cc->filterCut *= 0.5;
}
printf( "old filter params: " );
qDebug( "old filter params: " );
dump_mem( text, text_len );
break;
@@ -1276,7 +1271,7 @@ if( p.currentEffectChannel <= NumFxChannels )
{
const int bpae = 12;
const int imax = text_len / bpae;
printf( "automation data (%d items)\n", imax );
qDebug( "automation data (%d items)\n", imax );
for( int i = 0; i < imax; ++i )
{
FL_Automation a;
@@ -1288,8 +1283,9 @@ if( p.currentEffectChannel <= NumFxChannels )
if( a.channel >= 0 &&
a.channel < p.numChannels )
{
printf("add channel %d at %d val %d control:%d\n", a.channel, a.pos, a.value, a.control );
p.channels[a.channel].automationData += a;
qDebug( "add channel %d at %d val %d control:%d\n",
a.channel, a.pos, a.value, a.control );
p.channels[a.channel].automationData += a;
}
// dump_mem( text+i*bpae, bpae );
}
@@ -1315,14 +1311,14 @@ printf("add channel %d at %d val %d control:%d\n", a.channel, a.pos, a.value,
note n( len, pos, key, vol * 100 / 128,
pan*200 / 128 - 100 );
p.channels[ch].notes.push_back( qMakePair( p.currentPattern, n ) );
printf( "note: " );
qDebug( "note: " );
dump_mem( text+i*bpn, bpn );
}
break;
}
case FLP_Text_ChanGroupName:
printf( "channel group name: %s\n", text );
qDebug( "channel group name: %s\n", text );
break;
// case 216: pi[2] /= p.versionSpecificFactor
@@ -1353,7 +1349,7 @@ p.effectChannels[ch].volume = ( val / p.versionSpecificFactor ) * 100 / 128;
}
else
{
printf("FX-ch: %d param: %x value:%x\n", ch, param, val );
qDebug( "FX-ch: %d param: %x value:%x\n", ch, param, val );
}
}
break;
@@ -1378,7 +1374,7 @@ if( pat > 2146 && pat <= 2278 ) // whatever these magic numbers are for...
}
else
{
printf( "playlist item: " );
qDebug( "unknown playlist item: " );
dump_mem( text+i*bpi, bpi );
}
}
@@ -1388,25 +1384,18 @@ else
default:
if( ev >= FLP_Text )
{
printf( "!! unhandled text (ev: %d, "
"len: %d): ",
ev, text_len );
qDebug( "!! unhandled text (ev: %d, len: %d): ",
ev, text_len );
dump_mem( text, text_len );
}
else
{
printf( "!! handling of FLP-event %d "
"not implemented yet "
"(data=%d).\n", ev, data );
qDebug( "!! handling of FLP-event %d not implemented yet "
"(data=%d).\n", ev, data );
}
break;
}
/* if( ev >= FLP_Text )
{
printf( "dump (ev: %d, len: %d): ", ev, text_len );
dump_mem( text, text_len );
}*/
}
}
// now create a project from FL_Project data structure
@@ -1423,7 +1412,7 @@ else
progressDialog.setMaximum( p.maxPatterns + p.channels.size() +
p.effects.size() );
p.effects.size() );
int cur_progress = 0;
// create BB tracks
@@ -1479,8 +1468,7 @@ else
case FL_Plugin::UnknownPlugin:
default:
it->instrumentPlugin =
t->loadInstrument(
"audiofileprocessor" );
t->loadInstrument( "audiofileprocessor" );
break;
}
processPluginParams( &( *it ) );
@@ -1503,8 +1491,7 @@ else
iss->m_filterResModel.minValue() );
iss->m_filterEnabledModel.setValue( it->filterEnabled );
for( QList<FL_Channel_Envelope>::iterator jt =
it->envelopes.begin();
for( QList<FL_Channel_Envelope>::iterator jt = it->envelopes.begin();
jt != it->envelopes.end(); ++jt )
{
if( jt->target != instrumentSoundShaping::NumTargets )
@@ -1553,8 +1540,7 @@ else
}
// process all notes
for( FL_Channel::noteVector::const_iterator jt =
it->notes.begin();
for( FL_Channel::noteVector::const_iterator jt = it->notes.begin();
jt != it->notes.end(); ++jt )
{
const int pat = jt->first;
@@ -1563,8 +1549,7 @@ else
{
continue;
}
pattern * p = dynamic_cast<pattern *>(
t->getTCO( pat ) );
pattern * p = dynamic_cast<pattern *>( t->getTCO( pat ) );
if( p != NULL )
{
p->addNote( jt->second, false );
@@ -1583,8 +1568,7 @@ else
{
case FL_Automation::ControlVolume:
m = t->volumeModel();
value *= ( 100.0f / 128.0f ) /
p.versionSpecificFactor;
value *= ( 100.0f / 128.0f ) / p.versionSpecificFactor;
break;
case FL_Automation::ControlPanning:
m = t->panningModel();
@@ -1612,9 +1596,9 @@ else
value = mappedFilter[jt->value];
break;
default:
printf( "handling automation data of "
"control %d not implemented "
"yet\n", jt->control );
qDebug( "handling automation data of "
"control %d not implemented "
"yet\n", jt->control );
break;
}
if( m )
@@ -1652,14 +1636,12 @@ p->putValue( jt->pos, value, false );
else
{
effKeys << effectKey( &( *it ), it->name );
}
}
for( int fx_ch = 0; fx_ch <= NumFxChannels ; ++fx_ch )
{
fxChannel * ch = engine::getFxMixer()->getEffectChannel(
fx_ch );
fxChannel * ch = engine::getFxMixer()->getEffectChannel( fx_ch );
if( !ch )
{
continue;
@@ -1723,7 +1705,7 @@ p->putValue( jt->pos, value, false );
}
effectChain * ec = &engine::getFxMixer()->
getEffectChannel( it->fxChannel )->m_fxChain;
printf("adding %s to %d\n", effName.toUtf8().constData(),
qDebug( "adding %s to %d\n", effName.toUtf8().constData(),
it->fxChannel );
for( effectKeyList::iterator jt = effKeys.begin();
jt != effKeys.end(); ++jt )
@@ -1733,7 +1715,7 @@ p->putValue( jt->pos, value, false );
( jt->desc->sub_plugin_features != NULL &&
jt->name.contains( effName ) ) )
{
printf("instantiate %s\n", jt->desc->name );
qDebug( "instantiate %s\n", jt->desc->name );
effect * e = effect::instantiate(
jt->desc->name, ec, &( *jt ) );
ec->appendEffect( e );
@@ -1786,7 +1768,7 @@ p->putValue( jt->pos, value, false );
void flpImport::processPluginParams( FL_Channel * _ch )
{
printf( "plugin params for plugin %d (%d bytes): ", _ch->pluginType,
qDebug( "plugin params for plugin %d (%d bytes): ", _ch->pluginType,
_ch->pluginSettingsLength );
dump_mem( _ch->pluginSettings, _ch->pluginSettingsLength );
switch( _ch->pluginType )
@@ -1875,7 +1857,7 @@ void flpImport::processPluginParams( FL_Channel * _ch )
case FL_Plugin::UnknownPlugin:
default:
printf( "handling of plugin params not implemented "
qDebug( "handling of plugin params not implemented "
"for current plugin\n" );
break;
}