Skip to content

Solved Issues

gilpanal edited this page Jan 30, 2023 · 20 revisions
  • waveform-playlist: To allow manually deleting a single track from the playlist it was necessary to introduce a small change at node_modules/waveform-playlist/lib/Playlist.js in line:
          key: 'clear',
          value: function clear(trackPos) {
               var _this11 = this;           
               return this.stop().then(function () {
                   var newArray = [] 
                   if(trackPos || trackPos === 0){
                       _this11.tracks.splice(trackPos, 1)
                       newArray = _this11.tracks
                   }     
                  _this11.tracks = newArray;
  • waveform-playlist: File node_modules/waveform-playlist/lib/Playlist.js. To export only the track just recorded
  
 [...] 
  // line 260
  ee.on('startaudiorendering', function (type, trackPos) {
        _this2.startOfflineRender(type, trackPos);
  });

  [...]
  // line 524
  key: 'startOfflineRender',
    value: function startOfflineRender(type, trackPos) {      
      var _this4 = this;
      
      if (this.isRendering) {
        return;
      }

      this.isRendering = true;
      this.offlineAudioContext = new OfflineAudioContext(2, 44100 * this.duration, 44100);

      var currentTime = this.offlineAudioContext.currentTime;

      this.tracks.forEach(function (track, pos) { 
          let shouldPlay = _this4.shouldTrackPlay(track)
          if(trackPos >= 0 ){            
            shouldPlay = pos === trackPos
          }         
          track.setOfflinePlayout(new _Playout2.default(_this4.offlineAudioContext, track.buffer));
          track.schedulePlay(currentTime, 0, 0, {
            shouldPlay: shouldPlay,        
            masterGain: 1,
            isOffline: true
          });        
       
      });

      /*
        TODO cleanup of different audio playouts handling.
      */
      this.offlineAudioContext.startRendering().then(function (audioBuffer) {

        if (type === 'buffer') {
          _this4.ee.emit('audiorenderingfinished', type, audioBuffer);
          _this4.isRendering = false;
          return;
        }

        if (type === 'wav') {
          _this4.exportWorker.postMessage({
            command: 'init',
            config: {
              sampleRate: 44100
            }
          });

          // callback for `exportWAV`
          _this4.exportWorker.onmessage = function (e) {
            _this4.ee.emit('audiorenderingfinished', type, e.data, trackPos);
            _this4.isRendering = false;

            // clear out the buffer for next renderings.
            _this4.exportWorker.postMessage({
              command: 'clear'
            });
          };

          // send the channel data from our buffer to the worker
          _this4.exportWorker.postMessage({
            command: 'record',
            buffer: [audioBuffer.getChannelData(0), audioBuffer.getChannelData(1)]
          });

          // ask the worker for a WAV
          _this4.exportWorker.postMessage({
            command: 'exportWAV',
            type: 'audio/wav'
          });
        }
      }).catch(function (e) {
        throw e;
      });
    }
  }
Clone this wiki locally