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: immediately playing sound (Read 6398 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

immediately playing sound

Hallo people,

i have a lot of short sounds in Playlist.
do you see a posibility to adress each one over item index to play immediately?
I would prefer to start the sound from autohotkey!

The following tests i have made:
1) Start each sound from autohotkey via run, ...
  >>> This works, but there is a delay from about 2s.
2) To get direct access to listview to set the cursor.
  >>> This fails.

Thank you,
Frank

immediately playing sound

Reply #1
Are you using any digital outputs in your playback chain? e.g. optical out from computer to amp.

This can cause a 0.5 - 1 second delay when you start playing.
Who are you and how did you get in here ?
I'm a locksmith, I'm a locksmith.

immediately playing sound

Reply #2
No this it not the point. My delay is caused by starting a completly new instance from foobar for each sound.
Better would be to held one instance with all sounds in it and then trigger each sound from an extern programm.

immediately playing sound

Reply #3
Run,Foobar path\foobar2000.exe /add /immediate "song path" /context_command:play "song path"

The problem with this is that,you will add the same song again and again.
Maybe adding a command line(if there is)that removes the duplicates but I don't know what command line that is.

Btw Autohotkey can play audio files too and if they are short sounds,it even preferable to use it rather than starting a program,wait for it to load and play the file

http://www.autohotkey.com/docs/commands/SoundPlay.htm
Use the "wait" parameter too.

immediately playing sound

Reply #4
Quote
http://www.hydrogenaudio.org/forums/index.php?showforum=34[/url] ]foobar2000 Development Forum Rules

This forum is for developer discussions only. If you have a problem / bug report / idea / feature request that isn't related to foobar2000 SDK, post it in an appropiate forum instead - tech support questions go to support forum, everything else goes to general forum.
All non-developer posts on this forum will be removed. Continued abuse of this forum will result in admin actions (warnings, account suspension).

Edit: It became Develop-y but not sure whether to move it back

immediately playing sound

Reply #5
@db1989
Your a realy quick guy - what have I asked that makes you angry to throw me out of forum for developer discussions.
May be its my bad englisch. I have got 2 answers to my question but unfortunately without any solution.

So I ask again. Is it possible to get the windowhandle from foobar-listbox to place the cursor directly to a track. For example to track 5.
After 0,5s I want to play the next sound, for examlple track 45 and so on. Important is to play the sounds directly - without delaytimes from 1s or more.

@vsub
Thank you for nswering, probaby you can't find this text because of forum shift.
Yes I play sounds directly with autohotkey but with foobar-indirektion here would be 2 smart advantages (and some more..)
1) I can regulate volume independent from system-volume
2) I can rearrange sounds in tracklist

thank you,
Frank

immediately playing sound

Reply #6
The elegant solution would be to write a component that listened on some sort of IPC mechanism and changed the track on request.
This could be as simple as having a message-only window that waited for a WM_USER message, using the fb2k API to change the track or playback state.

Additionally, something like foo_httpcontrol may even expose enough of a surface for you to interact with the player if you can make HTTP requests and can tolerate a component listening on a socket.
Stay sane, exile.

immediately playing sound

Reply #7
The elegant solution would be to write a component that listened on some sort of IPC mechanism and changed the track on request.
If a component provided the ability to play specific tracks, it could also offer commands in the main menu to start these tracks. The user could then bind these commands to (global) keyboard shortcuts in foobar2000. This could make AutoHotkey unnecessary for the simple purpose of playing individual tracks.

Leaving hypothetical components which are yet to be developed aside, I agree about checking whether foo_httpcontrol provides the necessary functionality.

immediately playing sound

Reply #8
If it's a 1:1 correspondence between tracks and buttons, sure.
As AHK is essentially a full-blown programming platform, the actual use case may be much more complex and it seems like OP wants to play track by computed ordinal.

We could at least agree on that manipulating UI elements by sending messages to them is a horrible horrible idea.
Stay sane, exile.

immediately playing sound

Reply #9
If it's a 1:1 correspondence between tracks and buttons, sure.
As AHK is essentially a full-blown programming platform, the actual use case may be much more complex and it seems like OP wants to play track by computed ordinal.
I know. I guess I didn't make this clear enough in my previous post.

We could at least agree on that manipulating UI elements by sending messages to them is a horrible horrible idea.
Definitely.

immediately playing sound

Reply #10
If a component provided the ability to play specific tracks,

foo_scheduler is able to change a track on request (create a new Action lists entry > Start playback from track [choose freely definable track]).

However in the manner the OP would need it to work it cannot be utilized.
This is HA. Not the Jerry Springer Show.

immediately playing sound

Reply #11
ok, thanks a lot for inspiration.
the solution with a view lines of ahk-code is working very well.

;  |----------------------------------------------
;  |foo-direct-sound-access  ahk-solution  14.4.2014
;  |----------------------------------------------
;  |
;  |- playing soundpatterns with foo triggered by an extern ahk-interface
;  |- each sound can bind to keyboard-button
;  |- sounds can simply be rearranged to another key without programing
;  |
;  |  this framework was testet with:  XP SP3 / ahk v1.0.48.05 / foo v1.3.1
;  |  have fun,
;  |  frank 
;  |
;  |1) playlist handling
;  |--------------------
;  |get current order in listview
;ControlSend, {4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1, ^a^c{home}{space}, foobar2000
;  |convert multselect clipbord-format to plain-text. cb.bat with following 2 lines
;  |cd C:\pv\System\CygwinPortable\App\Cygwin\bin\
;  |getclip.exe | putclip.exe
;RunWait, C:\pv\System\CygwinPortable\cb.bat,, hide
;  |rename soundfiles
;..
;  |start new playlist
;run, C:\pv\zw\foobar2000\foobar2000.exe "C:\Dokumente und Einstellungen\frank\Desktop\x.m3u"
;  |get window-handle for handling several instances of foo
;WinWait, foobar2000
;WinGet, hfoo_01, ID, foobar2000
;..
;  |
;  |2) start sound by "name-appended-id"
;  |------------------------------------
;ControlSend, {4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1, [01]{enter}, foobar2000
;ControlSend, {4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1, [02]{enter}, foobar2000
;.. 
;  |
;  |----------------------------------------------
;  |foo-direct-sound-access  ahk-solution  14.4.2014
;  |----------------------------------------------

immediately playing sound

Reply #12
... in the last post I've basically explaint my solution. However, this was still a bit abstract. Now I show you a screenshot with a little description.

Direct-Sound-Access
Development for XP SP3 / ahk v1.0.48.05 / foo v1.3.1

Attention: This approach does not claim to an exemplary solution because it bypasses a few common conventions. But no matter - the main thing is that's working. It's just fun quickly implement an idea into action and not stuck in the jungle of opinions and guidelines.


2 x foobar2000 players on the right side of the desktop and 2 tray icons with functions.

Main-Features
A) 2 x foobar2000 instances (green + blue)
B) Controlmenus in systray
C) Indexhandling for Direct-Sound-Access

@ A)
The green player is intended for the ordinary operation - listen to musicfiles. The blue player is intended to play soundfiles. These sounds are triggered by an external program. Both players can be hidden via the tray icons. The volume can be controlled via mouse wheel independently even if the players are hidden.

;(I) Send information to foobar2000
;2 possibilities to trigger the sound via Name-Index from an extern program.
;-----------------------------------------------------------------------------------------
;The sondfile "on.wav" will be renamed from Indexfunction to ",001~~~on.wav"
;If you know, when typing buttons ",001" listcontrol will mark the corresponding sound.
;The program simulates such key inputs. Via Index ,001 the sound will be started.
;-----------------------------------------------------------------------------------------

;1) Start Soundfile via AHK-command ControlSend
ControlSend, {4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1, `,001{enter}, ahk_id %foo2_gh%

;2)Start Soundfile via AHK-commands PostMessage
;This code you can convert more easier to other languages than example 1).
;foo2_gh = handle from blue foobar2000
co = {4B94B650-C2D8-40de-A0AD-E8FADF62D56C}1
id = ,001

loop, parse, id
{
zk := asc( a_loopfield)
PostMessage, 0x102, %zk%, 1, %co%, ahk_id %foo2_gh%
}
PostMessage, 0x100, 0x0d, 0, %co%, ahk_id %foo2_gh%
PostMessage, 0x101, 0x0d, 0, %co%, ahk_id %foo2_gh%

;(II) Get information from foobar2000
;To get some Infos from Playlist use the clipboard.
;Start with the clipboardtool insideclipboard or something similar for looking what clipboard has captured.
;In custom format "foobar_2000_playable_location_format" you will find well formated playlist entries.
;For example: With this data you can generate a playlist of marked entries on desktop with a RightClick to TrayIcon.


@ B)
The control menus are customized for the use of each player. In addition, 8 various click events on the tray icon will be distinguished.

Examples for the green player (Music):
Click on trayIcon:      next song
Double click on trayIcon:   next song + delete running song from playlist
... some more events are availible

Examples for the blue player (Soundfiles):
Click on trayIcon:      index soundfiles new
Double click on trayIcon:   play marked soundfiles
... some more events are availible

All functions work regardless the players are visible or hidden.

@ C)
Similar to the sound scheme of the windows operating system, I use a separate sound scheme for other purposes. An external program produces some events. Each event has an associated sound. In this example, the event # 1 would start the sound "on.wav". Thanks foobar2000 the assignment of sounds can be changed quickly. To associate the sound "off.wav" (in screenshot #10) with the event # 1,  "off.wav" must simply pushed over the sound "on.wav". Via tray menu, the list can then be reindexed and immediately event # 1 triggers the sound "off.wav". Of course, differnet playlists can be used for different sound schemes.


When a musikfreak meet's a programmer it's foobar2000 time,
Frank


immediately playing sound

Reply #13
Direct-Sound/Song-Access
Development for XP SP3 / ahk v1.0.48.05 / foo v1.3.1

An extension for indexing
To access the sounds an index at the beginning of the file name has been added so far. This index may be hidden. For that I use the datetime-stamp of the file.

With the following pattern you can produce indexnumbers 0-99.
,$pad_right($add($mul($substr(%last_modified%,15,16),60),$right(%last_modified%,2)),2,0)

Format for datetime-stamp is YYYYMMDDHH24MISS. For the index only use the 4 last digits ...MISS.
Examples: ...0000 > 0 / ...0139 > 99

With a slightly modified pattern indexfield ranges from 0 to 3599.
Examples: ...0000 > 0 / ...0140 > 100 /...5959 > 3599


Sound-list with indexes fixed in datetime-stamp

If a sound is replaced by another sound, it may be useful to keep the index change visible in the list. That's why I add an info at the old place. In the picture above the Sound #1 was replaced by the Sound #5.

It's funny to deal with foobar2000,
Frank