How about crossfade or beatmixing?

Got an idea? Missing something? Post your feature request here.

Moderator: moderators

How about crossfade or beatmixing?

Postby diffy » Sat Feb 18, 2012 9:52 pm

Could Subsonic support crossfading between tracks or even beatmixing?
Last edited by diffy on Tue Jul 03, 2012 10:01 am, edited 1 time in total.
diffy
 
Posts: 97
Joined: Fri Dec 30, 2011 11:28 pm
Location: Copenhagen, Denmark

Re: How about crossfade or beatmixing?

Postby ytechie » Sun Feb 19, 2012 6:46 am

diffy, I think I can do crossfading using javascript, but it needs to be thought out. I currently fade my music down when a video is played. (It happens automatically using javascript.) If I think it through, I might post it!

Hope that eventually this helps ;)
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: How about crossfade or beatmixing?

Postby BKKKPewsey » Sun Feb 19, 2012 12:17 pm

Well this I must see :D
If you can do a proper crossfade with only 1 player instance available this would produce true gapless playback.
The Holy Grail!!!!
I wait in anticipation :mrgreen:
Everyone is entitled to be stupid, Image but some abuse the privilege!

Due to the confusion from too many genres of music, we have decided to put both country music and rap music into the genre of Crap music.
User avatar
BKKKPewsey
 
Posts: 2080
Joined: Mon May 23, 2011 12:16 pm
Location: United Kingdom

Re: How about crossfade or beatmixing?

Postby ytechie » Sun Feb 19, 2012 10:24 pm

As I'm thinking about it, I realize that I might be able to get it to fade out and back in, but crossfading might be challenging to accomplish using one player. Still turning it over in my head though. :)
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: How about crossfade or beatmixing?

Postby ytechie » Sun Feb 19, 2012 10:32 pm

OK. Due to the nature of the flash player, I don't think it is possible to crossfade using javascript. It is possible to fade out the last few seconds of a song and fade in the next. Sorry. Trust me, if I find a way to crossfade, there will be a tutorial on how to do it right here!
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: How about crossfade or beatmixing?

Postby elinoras » Thu Jun 14, 2012 8:10 am

Hello ytechie,
you said you're able to fade out the last few seconds of a song and fade in the next.
How do I do that automatically to all playlist?

Many thanks.
elinoras
 
Posts: 1
Joined: Thu Jun 14, 2012 8:05 am

Fade music for video playback

Postby ytechie » Tue Jun 19, 2012 12:37 pm

This is how to fade out the audio in Subsonic when a video is played.

First we will edit playlist.jsp.

Add these to the variables in the script section:

Code: Select all
var playing = 0;
var volume = 100;
var mute = 0;


Also, add the following to the flashvars in createPlayer():

Code: Select all
volume:"100",
mute:"false"

Make sure to add a comma after each variable except the last.

To track if the music is playing, change the stateListener() function like so:

Code: Select all
function stateListener(obj) { // IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
   if (obj.newstate == "COMPLETED") {
      playing = 0;
      onNext(repeatEnabled);
   } else if (obj.newstate == "PLAYING") {
      playing = 1;
   } else if (obj.newstate == "PAUSED") {
      playing = 0;
   } else if (obj.newstate == "IDLE") {
      playing = 0;
   }
}


Now we have to add two functions to track volume and mute states:

Code: Select all
function volumeListener(obj) {
   volume = obj.percentage;
}
   
function muteListener(obj) {
   if (obj.state) {
      mute = 1;
   } else {
      mute = 0;
   }
}


Now we have to add the controllers to the playerReady() function by adding these two lines:

Code: Select all
player.addControllerListener("VOLUME", "volumeListener");
player.addControllerListener("MUTE", "muteListener");


so the playerReady() function should look like this:

Code: Select all
function playerReady(thePlayer) {
   player = $("player1");
   player.addModelListener("STATE", "stateListener");      
   player.addControllerListener("VOLUME", "volumeListener");
   player.addControllerListener("MUTE", "muteListener");
   getPlaylist();
}


Now we add the pauseNow() function:

Code: Select all
function pauseNow() {
   if (playing == 1) {
      if (mute == 1) {
         player.sendEvent("PLAY","false");
      } else {
         for (var i = volume; i > 0; i--) {
            player.sendEvent("VOLUME",i);
         }
         player.sendEvent("PLAY","false");
         player.sendEvent("VOLUME",volume);
      }
   }
}


Now we have to call the pauseNow() function when a video is played.
We are going to edit playAddDownload.jsp.

We are going to add "onclick="top.playlist.pauseNow()"" to the ${videoUrl} link:
When finished, it should look like this:

Code: Select all
<c:when test="${param.video}">
   <sub:url value="/videoPlayer.view" var="videoUrl">
      <sub:param name="path" value="${param.path}"/>
   </sub:url>
   <a href="${videoUrl}" target="main" onclick="top.playlist.pauseNow()">
      <img src="<spring:theme code="playImage"/>" alt="<fmt:message key="common.play"/>" title="<fmt:message key="common.play"/>"></a>
</c:when>


That's it! Now when you play a video, any non-muted music will fade out and pause, the video will begin playing, and then the music's volume will be restored.

Note: To use this modification on Subsonic 4.7, just replace "playlist" with "playQueue" where appropriate.

Hope this helps!
:D
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: How about crossfade or beatmixing?

Postby ninjapuffin » Tue Oct 30, 2012 3:34 pm

I would definitely vote for that addition of a crossfade option
ninjapuffin
 
Posts: 9
Joined: Thu Oct 25, 2012 4:45 am

Re: How about crossfade or beatmixing?

Postby Munger » Thu Jan 17, 2013 11:04 pm

ytechie wrote:OK. Due to the nature of the flash player, I don't think it is possible to crossfade using javascript. It is possible to fade out the last few seconds of a song and fade in the next. Sorry. Trust me, if I find a way to crossfade, there will be a tutorial on how to do it right here!


It is possible to do it with SoundManager, but really tricky - http://wheelsofsteel.net/

I have managed to implement streaming audio with crossfading in a very crude test harness, but it all goes to hell in a hand basket when the user decides to skip tracks during the crossfade period. If anyone does manage to figure it out, then please remember to provide an option not to crossfade consecutive tracks on the same album.
Munger
 
Posts: 22
Joined: Sat Mar 26, 2011 5:26 pm


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 3 guests