2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2009 by Christian Schoenebeck * |
* Copyright (C) 2003-2014 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
184 |
} |
} |
185 |
} |
} |
186 |
|
|
187 |
|
// private helper function to convert progress of a subprocess into the global progress |
188 |
|
inline void __notify_progress(RIFF::progress_t* pProgress, float subprogress) { |
189 |
|
if (pProgress && pProgress->callback) { |
190 |
|
const float totalrange = pProgress->__range_max - pProgress->__range_min; |
191 |
|
const float totalprogress = pProgress->__range_min + subprogress * totalrange; |
192 |
|
pProgress->factor = totalprogress; |
193 |
|
pProgress->callback(pProgress); // now actually notify about the progress |
194 |
|
} |
195 |
|
} |
196 |
|
|
197 |
|
// private helper function to divide a progress into subprogresses |
198 |
|
inline void __divide_progress(RIFF::progress_t* pParentProgress, RIFF::progress_t* pSubProgress, float totalTasks, float currentTask) { |
199 |
|
if (pParentProgress && pParentProgress->callback) { |
200 |
|
const float totalrange = pParentProgress->__range_max - pParentProgress->__range_min; |
201 |
|
pSubProgress->callback = pParentProgress->callback; |
202 |
|
pSubProgress->custom = pParentProgress->custom; |
203 |
|
pSubProgress->__range_min = pParentProgress->__range_min + totalrange * currentTask / totalTasks; |
204 |
|
pSubProgress->__range_max = pSubProgress->__range_min + totalrange / totalTasks; |
205 |
|
} |
206 |
|
} |
207 |
|
|
208 |
#endif // __LIBGIG_HELPER_H__ |
#endif // __LIBGIG_HELPER_H__ |