Skip to content

Commit

Permalink
Merge branch 'bug/opus-spectrogram-broken'
Browse files Browse the repository at this point in the history
  • Loading branch information
rassokhin-s committed Jan 27, 2021
2 parents cc790e9 + b33a275 commit 44846a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/model/recordings.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ var Recordings = {
if(err) { callback(err); return; }
audioTools.spectrogram(recording_path.path, cache_miss.file, {
pixPerSec : config("spectrograms").spectrograms.pixPerSec,
height : config("spectrograms").spectrograms.height
height : config("spectrograms").spectrograms.height,
...recording.uri.endsWith('.opus') && recording.sample_rate && { maxfreq: recording.sample_rate * 2 }
},function(status_code){
if(status_code) { callback({code:status_code}); return; }
cache_miss.retry_get();
Expand Down
6 changes: 3 additions & 3 deletions app/utils/audiotool.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ var audiotools = {
spectrogram : function(source_path, destination_path, options, callback){
if(options instanceof Function) { callback = options; }
options = options || {};

var args = [];
args.push(source_path);
args.push('-n');
if(options.maxfreq) {
args.push('-r', ((options.maxfreq/500)|0) + 'k'); // maximum frequency to show in spectrogram
args.push('rate', (options.maxfreq/2)|0); // maximum frequency to show in spectrogram
}
args.push('-n', 'spectrogram'); // sox spectrogram filter
args.push('spectrogram'); // sox spectrogram filter
args.push('-r', // output just the raw spectrogram image (no axes, no nothing)
'-y', ((options.height | 0) || 256) // set the spectrogram's height
);
Expand Down

0 comments on commit 44846a6

Please sign in to comment.