Skip to content

Audio File Processor #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cbj4074 opened this issue Apr 10, 2019 · 4 comments
Open

Audio File Processor #129

cbj4074 opened this issue Apr 10, 2019 · 4 comments
Assignees
Labels

Comments

@cbj4074
Copy link
Member

cbj4074 commented Apr 10, 2019

In the interest of ensuring that this since-deleted logic isn't overlooked when we write tests in relation to audio file processing, I'm hereby citing the relevant business rules:

https://github.com/indiehd/audio-manipulator/blob/7fc5d3ff29d46b2e5f3fe9b987f08614b1b6fe88/src/Flac/FlacConverter.php#L77-L113

and

https://github.com/indiehd/audio-manipulator/blob/7fc5d3ff29d46b2e5f3fe9b987f08614b1b6fe88/src/Flac/FlacConverter.php#L139-L160

// These toggles default to true, but may be changed hereafter, depending
// on the totality of the inputs supplied.

$performTrim = true;
$canFadeIn = true;
$canFadeOut = true;

// Determine whether or not the audio file is actually shorter than
// the specified clip length. This is done to prevent the resultant
// file from being padded with silence.

if ($fileDetails['playtime_seconds'] < $clipLength) {
    // No trim or fades are necessary if the play-time
    // is less than the specified clip length.

    $performTrim = false;
    $canFadeIn = false;
    $canFadeOut = false;
}

// This block prevents problems from a track preview start
// time that is too far into the track to allow for a preview clip of
// the specified length.

if (($fileDetails['playtime_seconds'] - $trimStartTime) < $clipLength) {
    // We'll force the track preview to start exactly $clipLength seconds
    // before the end of the track, thus forcing a $clipLength-second preview
    // clip length.

    $trimStartTime = $fileDetails['playtime_seconds'] - $clipLength;
}

// Convert the clip length from seconds to hh:mm:ss format.

$clipLength = Utility::sec2hms($clipLength, false, false);

if ($performTrim !== false) {
    $cmd[] = ' trim ' . escapeshellarg($trimStartTime) . ' ' . escapeshellarg($clipLength);
}

if ($canFadeIn !== false || $canFadeOut !== false) {
    $cmd[] = ' fade q ';

    if ($canFadeIn === false) {
        // Setting a fade-in length of zero in SoX is the
        // same as having no fade-in at all.

        $fadeInLength = '0';
    }

    $cmd[] = escapeshellarg($fadeInLength);

    if ($canFadeOut !== false) {
        $cmd[] = ' ' . escapeshellarg($clipLength) . ' ' . escapeshellarg($fadeOutLength);
    }
}
@cbj4074 cbj4074 added the todo label Apr 10, 2019
@cbj4074 cbj4074 self-assigned this Apr 10, 2019
@cbj4074 cbj4074 added this to the Audio File Processor milestone Apr 10, 2019
@cbj4074
Copy link
Member Author

cbj4074 commented Apr 11, 2019

Similarly, there is valuable, application-specific logic here that will need to be preserved in some capacity:

https://github.com/indiehd/audio-manipulator/blob/7fc5d3ff29d46b2e5f3fe9b987f08614b1b6fe88/src/Flac/FlacTagger.php#L326-L414

@cbj4074
Copy link
Member Author

cbj4074 commented May 5, 2019

I just released v2.0.0 of the required library, which is the version that should be required in this project, e.g., ^2.0.

@poppabear8883
Copy link
Contributor

Will you be requiring that package directly in or are you bridging it with a Laravel package ?

@cbj4074
Copy link
Member Author

cbj4074 commented May 5, 2019

That's a good point/question.

Some type of Laravel-specific bridge package would probably be ideal. I'll have to dig into it a bit deeper and see what the integration might look like. I'll post an update on this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants