diff --git a/src/plugin/regions.js b/src/plugin/regions.js
index <HASH>..<HASH> 100644
--- a/src/plugin/regions.js
+++ b/src/plugin/regions.js
@@ -56,10 +56,16 @@ class Region {
             params.channelIdx == null ? -1 : parseInt(params.channelIdx);
         this.regionHeight = '100%';
         this.marginTop = '0px';
-        let channelCount = this.wavesurfer.backend.ac.destination.channelCount;
-        if (channelIdx >= 0 && channelIdx < channelCount) {
-            this.regionHeight = Math.floor((1 / channelCount) * 100) + '%';
-            this.marginTop = this.wavesurfer.getHeight() * channelIdx + 'px';
+
+        if (channelIdx !== -1) {
+            let channelCount = 
+                this.wavesurfer.backend.buffer != null
+                ? this.wavesurfer.backend.buffer.numberOfChannels
+                : -1;
+            if (channelCount >= 0 && channelIdx < channelCount) {
+                this.regionHeight = Math.floor((1 / channelCount) * 100) + '%';
+                this.marginTop = this.wavesurfer.getHeight() * channelIdx + 'px';
+            }
         }
 
         this.bindInOut();
Regions plugin: fix channelCount assignment (#<I>)

* regions plugin: handle position fix while using with channelIdx param



* regions plugin: channelCount assignment source fix



* fix lint error