Skip to content

Commit

Permalink
add keyboard shortcut to show the current position in seconds
Browse files Browse the repository at this point in the history
Very helpful for setting up the fade out position.
  • Loading branch information
kajott committed Aug 13, 2024
1 parent d6644a2 commit fc00b72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The following other controls are available:
| Mouse Wheel | manually scroll through the metadata bar (stops autoscrolling)
| **A** | stop / resume autoscrolling
| **F** | slowly fade out the song
| **P** | show the current track position in seconds (hold key to update continuously)
| **V** | show the TrackMeister and libopenmpt version numbers
| **F5** | reload the current module and the application's configuration
| **F11** | toggle fullscreen mode
Expand Down Expand Up @@ -154,6 +155,7 @@ Options can also be specified on the command line, in the syntax "`+key=value`"
- Listen to the tracks again and set track-specific options in `tm.ini`. For each track you want to set special options for, you create a new section based on the running order, e.g. `[08*]` for the options of the file in the aforementioned example. <br> Typical per-track options are:
- If the track shall loop, set `loop = true`. If you also set `fade out after loop = true`, the track will also fade out at this point.
- If the track shall fade out at some position, set `fade out at =` to the number of seconds after which fading shall start (e.g. `fade out at = 123` fades out after 123 seconds, i.e. 2 minutes and 3 seconds).
- To determine the proper value, just pause playback at the position where you want the fade to start (using the **Space** key) and press the **P** key to display the position. The raw value in seconds can be directly used for the `fade out at` option.
- If the track shall be played in mono, set `stereo separation = 0`.
- If the track shall be played with some volume ramping, set `volume ramping = 10`; if it shall not use ramping, set `volume ramping = 0`.
- You can also override the track's title/artist metadata by setting it manually, e.g. `title = Professional Tracker` and `artist = H0ffman feat. Daytripper`.
Expand Down
12 changes: 12 additions & 0 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ void Application::handleKey(int key, bool ctrl, bool shift, bool alt) {
case 'V': // show version
toastVersion();
break;
case 'P': // show position
toastPosition();
break;
case 'F': // start fade-out
fadeOut();
break;
Expand Down Expand Up @@ -385,6 +388,15 @@ void Application::toastVersion() {
toast(ver);
}

void Application::toastPosition() {
if (!m_mod) { return; }
char line[80];
AudioMutexGuard mtx_(m_sys);
auto sec = m_mod->get_position_seconds();
sprintf(line, "current track position: %d:%02d (%.2f seconds)", int(sec) / 60, int(sec) % 60, sec);
toast(line);
}

void Application::updateImage(ExternalImage& img, const std::string& path, int channels, const char* what) {
int64_t mtime = PathUtil::getFileMTime(path.c_str());
if ((path != img.path) || (mtime > img.mtime)) {
Expand Down
1 change: 1 addition & 0 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class Application {
void toast(const char* msg);
inline void toast(const std::string& msg) { toast(msg.c_str()); }
void toastVersion();
void toastPosition();
void fadeOut();
void startScan(const char* specificFile=nullptr);
void runScan();
Expand Down

0 comments on commit fc00b72

Please sign in to comment.