Skip to content

Commit

Permalink
Fixed bug that occurs given a relative path and no outfile filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
lyaunzbe committed Feb 9, 2013
1 parent 10b5c01 commit d386a7f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Lute
# Lute

![lute](https://raw.github.com/lyaunzbe/lute/master/lute.jpeg)

Expand All @@ -17,7 +17,7 @@ Roadmap:
* Multiple outputs
* Pseudo effects (:newfile, :restart). Example: (sox infile.wav output.wav trim 0 30 : newfile : restart). Splits infile into n files, each 30 seconds in length.

### Installation
## Installation

Before installing the module, you will need to install SoX. If you have homebrew, this is as simple as:

Expand All @@ -42,9 +42,9 @@ var task = require('./path/to/your/task.json')

lute(['song1.wav', 'song2.mp3'], task, callback);
```
### Examples
## Examples

## Batch transcode, no output filenames given
### Batch transcode, no output filenames given
```javascript
var task = {
"outfile":{
Expand All @@ -55,7 +55,7 @@ var task = {
lute(['Track-1.flac', 'Track-2.flac'], task, callback);
// Outputs Track-1.mp3 & Track-2.mp3
```
## Transcode and flanger effect, w/ output filenames
### Transcode and flanger effect, w/ output filenames
```javascript
var task = {
"outfile":{
Expand All @@ -71,7 +71,7 @@ lute = (['Ride_With_It.flac', 'Sweet_Home_Alabama.flac'],task, callback);
// Outputs song1.wav and song2.wav
```

## Effect chain, no transcode and no output filenames
### Effect chain, no transcode and no output filenames
```javascript
var task = {
"effects":{
Expand All @@ -89,7 +89,7 @@ In general, if you aren't transcoding and dont provide any output
filenames, they will be provied for you in the format of
infile_epochtime.extension

### Testing
## Testing
```bash
npm test
```
5 changes: 3 additions & 2 deletions lib/lute.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

var _ = require('lodash'),
path = require('path'),
async = require('async'),
spawn = require('child_process').spawn;

Expand Down Expand Up @@ -38,12 +39,12 @@ module.exports = function (images, task, callback) {
var queue = async.queue(function (infile,cb){
if(!task.outfile || !task.outfile.filename){
var id = new Date().getTime();
var input = infile.split('.');
var input = path.basename(infile).split('.');
outfile = input[0] +id + '.' +input[1];
}

args = _.flatten([infile, outfile, effects]);

console.log(args);
var process = spawn('sox',args);

process.on('exit', function(code){
Expand Down
4 changes: 1 addition & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ var test = require('tap').test,
phaser = require('./../tasks/phaser.json'),
lute = require('./../lib/lute');


/*
* Testing module and task definition.
*
*/
test('Module definition', function(t){
t.plan(2);
t.type(lute, 'function', 'Lute should be a funciton.');
t.type(phaser,'object', 'Task should be an object.');
t.end();
Expand All @@ -21,11 +21,9 @@ test('Processesing an example task', function(t){
t.plan(1);
lute(['rick.ogg', 'showtime.ogg'], phaser, function(err){
t.equal(null, err, 'Should return no errors or warnings');
t.end();
});
});


/**
* A more complicated effect chain, using format options for
* the output file. Ensure no errors.
Expand Down

0 comments on commit d386a7f

Please sign in to comment.