Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: foo_tfsandbox (Read 16481 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foo_tfsandbox

This component provides an editor for title formatting code. The editor includes syntax highlighting, a preview of the selected fragment of the code and a view of the code structure. The idea behind the component is to allow users to explore title formatting scripts by exposing aspects which are normally hidden on the user interface of foobar2000 and its components.

The component is mainly targeted at title formatting beginners. I do not intend to add advanced IDE features. I am aware that some parts of the component only work well for small scripts. This applies both to the chosen presentation and the performance. Fixing these performance issues is not very high on my list of priorities. A simple remedy is to not torture the component with hundreds of lines of title formatting code.



Installation

Download the component from the releases page on github.com or from the official foobar2000 component site. Links to both side can be found at the end of this post. Use the normal procedure to install the component package.

If you insist on unpacking the component package and installing the component manually make sure to install all three DLL contained in the package into the same folder. Do not try to replace the SciLexer.dll from this component with the one from foo_wave_seekbar or vice versa!

Usage

Use the "Title Formatting Sandbox" command in the "View" menu of the main menu to open the Title Formatting Sandbox window. Use the close button in the title bar of the window to close it. The window remembers its position and editor content when it is closed.

The window consists of three parts: the editor, the structure view and the preview field.

The editor covers the middle and top left side of the window. You can edit title formatting code here. The editor provides syntax highlighting to distinguish different types of title formatting constructs (text, fields, function calls). It uses dimmed colours to mark code which is not executed for the playing track, e.g. the branch of an $if statement which was not taken. A translucent background indicates the smallest syntactically correct fragment of code which contains the current selection or the current cursor position if the selection is empty. The value of this fragment will be displayed in the preview field. The editor also displays a tooltip for an expression if you hover the moise pointer over it.

The structure view is on the right side of the window. It displays the structure of the code using a tree view. The labels of the entries are coloured using the same colours as in the editor. The value of the selected entry will be displayed in the preview field.

The preview field is on the bottom side of the window. It displays the value of the selected fragment of title formatting code. The selected fragment is taken either from the editor or the structure view depending on which one of these has the focus. The value of the fragment is determined based on the playing track in the context of the entire title formatting code in the editor. This means if you select a function call like "$get(X)" the preview field will display the value the variable X has at this point in the code.

Consistency with foobar2000

The component tries to interpret title formatting code in the same way as foobar2000 itself. In same cases it was not practical to be perfectly consistent with foobar2000. Most of these will not be relevant to the average user. They are documented here anyway for completeness.

There are some cases where the component uses a stricter title formatting syntax than foobar2000 itself. For example it always treats commas as special characters. If you want a comma to be treated as text you need to enclose it in single quotation marks. This is good practice anyway and makes the grammar simpler.

There are also some cases where the component evaluates title formatting code differently than foobar2000 itself. A notable example is the Boolean value of a constant expression. The foobar2000 title formatting compiler evaluates expressions at compile time if they only contain constants and some of the built-in functions. The compiler then replaces the expression with a string constant whose Boolean value is always false. I consider this to be a bug in the title formatting compiler and made no effort to reproduce the effect in this component.

Links

foo_tfsandbox

Reply #1
Already been useful.
Thanks foosion.

C.
PC = TAK + LossyWAV  ::  Portable = Opus (130)

foo_tfsandbox

Reply #2
Thanks foosion, looking forward to getting better with title formatting with this!

foo_tfsandbox

Reply #3
Thanks foosion. Should be really useful for starters.

Only thinking out loud in this post. Don't take anything I say as a serious request.

At a quick glance, things I thought newbies may run into that aren't currently 'addressed':
- Special fields: %isplaying%, %list_index%. Maybe show 'Not available in this context' as output with a different color/icon when the exact line is highlighted? Ignore otherwise?
- Tag splitting: %<genre>%. Album list specific, but given the popularity of that component among starters, I expect it to come up often.
- Columns UI stuff: $rgb(). Colorize the output? Ignore? Ignore with a warning that it's only available when using CUI?
- Special characters: ★. Foobar shows these just fine even when $char() is not used. Show it, but maybe tell them to do so?

Perhaps add a quick link to the titleformatting wiki? It will be redundant with 'Help/Title formatting help', but does newbies even notice that?

While we are at it, perhaps advertise the component on the wiki page from now on?


foo_tfsandbox

Reply #5
Five seconds after installing...I swear I didn't try to do this on purposes, foosion. 

http://i.imgur.com/3uwKtTW.png

Unicode - is it me or does it need some loving?

foo_tfsandbox

Reply #6
Thanks for the feedback everyone! I actually started this component quite some time ago but it had been gathering dust for a few years now. I picked it up in the second half of 2014 and gave it some polish. There are still a few more feature I would like to see in the component, Daeron found some of them.  I am in a hurry now so I will comment the suggestions later.

foo_tfsandbox

Reply #7
And we have the first bug report. It looks like the preview field is not set up to use UTF-8. Thanks for reporting!

foo_tfsandbox

Reply #8
The really essential component, thanks)
last.fm | bulletproof2k

foo_tfsandbox

Reply #9
Thank you, foosion. Excellent plug-in.
That's so plausible, I can't believe it.

foo_tfsandbox

Reply #10
Thanks foosion!!! Very useful for beginners

foo_tfsandbox

Reply #11
This looks very handy, always used Notepad+ before but I think I will use this instead.

foo_tfsandbox

Reply #12
Version 1.0.1 is out. It fixes the bug reported by MachineHead.

 

foo_tfsandbox

Reply #13
Outstanding, thanks for this! Here is my first little issue I didn't notice before:

When I enter my conversion code everything works perfectly but this sandbox shows two \\, how do I clean this? Thanks.

Code:
Code: [Select]
$if($meta(album artist,0),%album artist%\[%date% - ][%album%]\[D%discnumber%]\[%tracknumber%. ][%title%],[%artist%]\[%date% - ][%album%]\[D%discnumber%]\[%tracknumber%. ][%title%])


Screenshot:
No multiple discs, no Various Artists


Multiple discs:


Various Artists:


Various Artists, multiple discs:

foo_tfsandbox

Reply #14
for example:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%])

foo_tfsandbox

Reply #15
Perfect, thanks lvqcl.

Lossy:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%])

Lossless:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%' [L]'\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%' [L]'\][D%discnumber%\][%tracknumber%. ][%title%])

Car:
Code: [Select]
$if($meta(album artist,0),%album artist% [[%date% ]%album%\][D%discnumber% ][%tracknumber% ][%title%],[%artist% ][[%date% ]%album%\][D%discnumber% ][%tracknumber% ][%title%])

foo_tfsandbox

Reply #16
...
The component is mainly targeted at title formatting beginners. I do not intend to add advanced IDE features. I am aware that some parts of the component only work well for small scripts. This applies both to the chosen presentation and the performance. Fixing these performance issues is not very high on my list of priorities. A simple remedy is to not torture the component with hundreds of lines of title formatting code.
...

What is IDE?


foo_tfsandbox

Reply #18
Perfect, thanks lvqcl.

Lossy:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%\][D%discnumber%\][%tracknumber%. ][%title%])

Lossless:
Code: [Select]
$if($meta(album artist,0),%album artist%\[[%date% - ]%album%' [L]'\][D%discnumber%\][%tracknumber%. ][%title%],[%artist%]\[[%date% - ]%album%' [L]'\][D%discnumber%\][%tracknumber%. ][%title%])

Car:
Code: [Select]
$if($meta(album artist,0),%album artist% [[%date% ]%album%\][D%discnumber% ][%tracknumber% ][%title%],[%artist% ][[%date% ]%album%\][D%discnumber% ][%tracknumber% ][%title%])

I just started looking at this. What distinguishes Lossy, Lossless and Car above?

foo_tfsandbox

Reply #19
Hi.
I'm using default user interface of foobar 1.3.9 (foo_ui_std 0.9.5).
I downloaded this component today and started some "experiments", so I have few questions:

1. why variables like %list_total% is not working in status bar formatting i.e.: ★ Now playing: %artist% - %title% | total tracks: %list_total%
http://wiki.hydrogenaud.io/index.php?title...25list_total.25
and where can I use this variables ?

2. why variables like %play_count% is not working in status bar formatting [Titleformat Playback Statistics]
http://wiki.hydrogenaud.io/index.php?title...back_Statistics
and where can I use this variables ?

3. do I need "Playback Statistics Component" or foobar have build in some functions of statistics ?:
http://www.foobar2000.org/components/view/foo_playcount
http://wiki.hydrogenaud.io/index.php?title...(foo_playcount)

Thanks fo any reply 

foo_tfsandbox

Reply #20
1. why variables like %list_total% is not working in status bar formatting i.e.: ? Now playing: %artist% - %title% | total tracks: %list_total%
http://wiki.hydrogenaud.io/index.php?title...25list_total.25
and where can I use this variables ?
%list_total% works in the playlist (and a few other places which deal with lists).

2. why variables like %play_count% is not working in status bar formatting [Titleformat Playback Statistics]
http://wiki.hydrogenaud.io/index.php?title...back_Statistics
and where can I use this variables ?

3. do I need "Playback Statistics Component" or foobar have build in some functions of statistics ?:
http://www.foobar2000.org/components/view/foo_playcount
http://wiki.hydrogenaud.io/index.php?title...(foo_playcount)
There is no built-in playback statistics function. You need foo_playcount for that and the %play_count% field.

Note that many special fields and functions are not available in the title formatting sandbox. The sandbox only supports the functions and fields which work everywhere.

Re: foo_tfsandbox

Reply #21
Thank you for this component! I guess, I've searched my half foobar2000-life for such a useful goodie! And now, I've found it accidentially while browsing the f2k-components-pages looking for something completely different....will give it a try.

Note that many special fields and functions are not available in the title formatting sandbox. The sandbox only supports the functions and fields which work everywhere.
Hope, I keep that in mind....

Re: foo_tfsandbox

Reply #22
So far, that component is a WIN! thank you again.

Would it be possible to allow resizing of that window?

Maybe also allow to move/resize those single parts (the code, the tree view and the result) of the windows?
(and remember their positions the next time, the component is started)

That would help much dealing with long and complex code.



Re: foo_tfsandbox

Reply #23
Resizing the window is already on my private wishlist. In the mean time the best way to deal with complex title formatting code inside and outside of the component is to add line breaks. ;)

Re: foo_tfsandbox

Reply #24
+1 for window resizing (option to make it full screen + drag & drop of the splitters). I hope that won't be too long to implement sometime soon.  O:)