MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Sound loop not seamless. Request advice.

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    7 Posts 3 Posters 2.0k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • justjim1220J Offline
      justjim1220 Module Developer @Mykle1
      last edited by

      @mykle1

      I remember having a similar issue with HTMl a long time ago, what I ended up doing was making 3 copys of the wav file and looping through them where one ended at a certain time and the other would start at the same time. But I had to time the gap, and set the time to start the next wav file at that point of the current wav file. I don’t remember the exact coding, been a while now, but after getting it to loop through the 3 copys, starting the next wav at the end of the current wav minus the gap time.

      IE: if the wav files are 1.75s, and if the gap was 0.25s, then the next wav would start at 1.5s of the current wav.

      If that makes any sense, apologies if it doesn’t.

      "Life's Too Short To Dance With Ugly People"
      Jim Hallock - 1995

      Mykle1M 1 Reply Last reply Reply Quote 0
      • Mykle1M Offline
        Mykle1 Project Sponsor Module Developer @justjim1220
        last edited by

        @justjim1220

        Makes sense but I’m not willing to make 3 copies of each sound file that will accompany the module, not to mention editing each and every one of them.

        Create a working config
        How to add modules

        justjim1220J 1 Reply Last reply Reply Quote 0
        • justjim1220J Offline
          justjim1220 Module Developer @Mykle1
          last edited by

          @mykle1

          I understand that, It was a lot of work for me

          Was thinking though, I think I only used 2 copies.

          "Life's Too Short To Dance With Ugly People"
          Jim Hallock - 1995

          1 Reply Last reply Reply Quote 0
          • Mykle1M Offline
            Mykle1 Project Sponsor Module Developer
            last edited by

            For those interested in helping me find a solution. I had intermittent success (sort of) with this function

            myAudio = new Audio('modules/MMM-SoundMachine/sounds/rain.wav');
            myAudio.addEventListener('ended', function() {
            this.currentTime = 0;
            this.play();
            }, false);
            myAudio.play();
            
            var audio = new Audio('modules/MMM-SoundMachine/sounds/rain.wav');
            
            audio.addEventListener('canplaythrough', function() {
            this.currentTime = this.duration - 10;
            this.loop = true;
            this.play();
            });
            

            Half of the time the module would error
            Failed to load resource: net::ERR_CACHE_OPERATION_NOT_SUPPORTED
            This did not stop the module from loading but the sound file still has the gap when looping.

            The other half of the time the module would not error and the gap would be gone, a seamless loop. However, the sound would be distorted, almost as if the sound were playing twice, but offset. At least I’ve made some progress.

            Still, I await assistance at your leisure, friends. :-)

            Create a working config
            How to add modules

            1 Reply Last reply Reply Quote 0
            • ? Offline
              A Former User
              last edited by

              Very interesting issue. Is it worked on RPI also?

              Mykle1M 1 Reply Last reply Reply Quote 0
              • Mykle1M Offline
                Mykle1 Project Sponsor Module Developer @Guest
                last edited by

                @sean

                Hi sean. No, I have not tried it on a Pi, yet. I only just started developing the module and came upon this issue. When/if I can solve this, the PI will get its chance.

                Create a working config
                How to add modules

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Enjoying MagicMirror? Please consider a donation!
                MagicMirror created by Michael Teeuw.
                Forum managed by Sam, technical setup by Karsten.
                This forum is using NodeBB as its core | Contributors
                Contact | Privacy Policy