AndreyS Posted March 22, 2016 Share Posted March 22, 2016 Dear developers are faced with the problem of who is trying to resolve already probably a few weeks. I decided to address you as a specialist. The challenge is to program to lose two parts audio record split in half. As much as I tried to do it and whatever function is not used, there is always a delay and audible pause at the beginning of the launch of the second part. Note also that the weaker processor and the larger the file size, the more pause. How can I play the two parts together so that there is no audible pause and transition? It is necessary to implement it. #include <Sound.au3> Dim $SFile1 = _SoundOpen("1-1.mp3") Dim $SFile2 = _SoundOpen("1-2.mp3") _SoundPlay($SFile1,1) _SoundPlay($SFile2,1) Please help me solve it. Thank you! 1.mp3 1-1.mp3 1-2.mp3 Link to comment Share on other sites More sharing options...
InunoTaishou Posted March 22, 2016 Share Posted March 22, 2016 (edited) I couldn't hear a *noticable* pause doing it this way #include <Sound.au3> Dim $SFile1 = _SoundOpen("1-1.mp3") Dim $SFile2 = _SoundOpen("1-2.mp3") Local $iWaitTime = _SoundLength($SFile1, 2) _SoundPlay($SFile1,0) Sleep($iWaitTime - 100) _SoundPlay($SFile2,1) Edited March 22, 2016 by InunoTaishou Link to comment Share on other sites More sharing options...
AndreyS Posted March 22, 2016 Author Share Posted March 22, 2016 Thank you for your attention and participation! Such a decision, I also tried to apply. Clicks on the transition. In addition, the pause on different computers will be different. You have perfect sound with a value of 100. And I heard a click. We need the best and universal solution. Link to comment Share on other sites More sharing options...
BrewManNH Posted March 22, 2016 Share Posted March 22, 2016 _Soundplay is very basic, you're asking too much from it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MuffinMan Posted March 22, 2016 Share Posted March 22, 2016 (edited) @AndreyS, Have you tried concatenating the files before playing? I downloaded the 2 files and from a DOS prompt ran copy /b 1-1.mp3 + 1-2.mp3 final.mp3 and played final.mp3 through my PC with no perceptible skip glitch or pause between the 2 9 second tracks. You should be able to script that pretty easily. Try this... #include <Sound.au3> Dim $SFile1 = "1-1.mp3" Dim $SFile2 = "1-2.mp3" RunWait(@ComSpec & " /c copy /b " & $Sfile1 & " + " & $SFile2 & " final.mp3") $Final = _SoundOpen("final.mp3") _SoundPlay($Final,1) Edited March 22, 2016 by MuffinMan added code Link to comment Share on other sites More sharing options...
AndreyS Posted March 22, 2016 Author Share Posted March 22, 2016 (edited) They can not connect. They are specifically and broke up at the beginning. This is just an example. There will be a lot of pieces that will be played in a very different order. Besides, I did not want to have a hard disk and CPU load such file operations. Thank you, MuffinMan, for your participation! Wow! This is something very powerful too! Thank you, BrewManNH, for your participation and the link! I tried to implement my problem with this UDF. Maybe I did something wrong, but I still audible clicking. Tell me, please, how to better implement it. expandcollapse popup#include <Bass.au3> #include <BassConstants.au3> Global $playing_state = -1 ;Open Bass.DLL. Required for all function calls. _BASS_STARTUP ("BASS.dll") ;Initalize bass. Required for most functions. _BASS_Init(0, -1, 44100, 0, "") ;Check if bass iniated. If not, we cannot continue. If @error Then MsgBox(0, "Error", "Could not initialize audio") Exit EndIf ;Prompt the user to select a MP3 file $file1 = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)") $file2 = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)") ;Create a stream from that file. $MusicHandle1 = _BASS_StreamCreateFile(False, $file1, 0, 0, 0) $MusicHandle2 = _BASS_StreamCreateFile(False, $file2, 0, 0, 0) ;Iniate playback _BASS_ChannelPlay($MusicHandle1, 1) $song_length = _BASS_ChannelGetLength($MusicHandle1, $BASS_POS_BYTE) While _BASS_ChannelGetPosition($MusicHandle1, $BASS_POS_BYTE)<>$song_length WEnd _BASS_ChannelPlay($MusicHandle2, 1) $song_length = _BASS_ChannelGetLength($MusicHandle2, $BASS_POS_BYTE) While _BASS_ChannelGetPosition($MusicHandle2, $BASS_POS_BYTE)<>$song_length WEnd Func OnAutoItExit() ;Free Resources _BASS_Free() EndFunc ;==>OnAutoItExit Edited March 22, 2016 by AndreyS Link to comment Share on other sites More sharing options...
Danyfirex Posted March 23, 2016 Share Posted March 23, 2016 Hi. You can do something like this. expandcollapse popup#include <Bass.au3> #include <BassConstants.au3> #include <WinAPI.au3> Global $playing_state = -1 ;Open Bass.DLL. Required for all function calls. _BASS_STARTUP("BASS.dll") ;Initalize bass. Required for most functions. _BASS_Init(0, -1, 44100, 0, "") ;Check if bass iniated. If not, we cannot continue. If @error Then MsgBox(0, "Error", "Could not initialize audio") Exit EndIf ;Prompt the user to select a MP3 file $sFilePath1 = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)") $sFilePath2 = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)") Local $iFileSize1 = FileGetSize($sFilePath1) Local $iFileSize2 = FileGetSize($sFilePath2) If $iFileSize1 and $iFileSize2 Then Local $tBuffer = DllStructCreate("byte StreamFile1[" & $iFileSize1 & "];byte StreamFile2[" & $iFileSize2 & "]") Local $pMemory=DllStructGetPtr($tBuffer) $tBuffer.StreamFile1=FileRead($sFilePath1) $tBuffer.StreamFile2=FileRead($sFilePath2) Local $hMusic = _BASS_StreamCreateFile(True, $pMemory, 0, $iFileSize1 + $iFileSize2, 0) Local $song_length = _BASS_ChannelGetLength($hMusic, $BASS_POS_BYTE) _BASS_ChannelPlay($hMusic, 1) While True If _BASS_ChannelGetPosition($hMusic, $BASS_POS_BYTE) = $song_length Then ExitLoop WEnd EndIf Func OnAutoItExit() ;Free Resources _BASS_Free() EndFunc ;==>OnAutoItExit Saludos AndreyS 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
AndreyS Posted March 23, 2016 Author Share Posted March 23, 2016 Yes, sounds are now together! Thank you! There is hope now! And you can still somehow simplify the code? You can use only the function of Bass.au3? And at the end of play audible sounds precipitous ending of the second file 4 times for about 200 ms. Because of what these overtones? Link to comment Share on other sites More sharing options...
Danyfirex Posted March 23, 2016 Share Posted March 23, 2016 simplify ? It's simple... I dont understand your point aobut ending... Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
AndreyS Posted March 23, 2016 Author Share Posted March 23, 2016 (edited) Listen to these overtones in the end. The noise did not pay attention - I wrote the sound from the speakers. VOICE160323002.mp3 Edited March 23, 2016 by AndreyS Link to comment Share on other sites More sharing options...
Danyfirex Posted March 23, 2016 Share Posted March 23, 2016 mmm rare. I tested over Windows 10 and windows 7. I dont have overtones in the end. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
AndreyS Posted March 23, 2016 Author Share Posted March 23, 2016 )) Maybe just a problem in my Windows 8.1 However, how does this allow?! Function _SoundPlay this effect does not. Link to comment Share on other sites More sharing options...
Danyfirex Posted March 23, 2016 Share Posted March 23, 2016 mmm I don't think. When you open 1-1.mp3 and 1-2.mp3 what is your channel length? I got 3105792? Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
AndreyS Posted March 23, 2016 Author Share Posted March 23, 2016 The length is the same: 3105792 Link to comment Share on other sites More sharing options...
Danyfirex Posted March 23, 2016 Share Posted March 23, 2016 Try adding _Bass_SampleStop after while ends. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
AndreyS Posted March 23, 2016 Author Share Posted March 23, 2016 I noticed that other files are no such overtones in the end. But there is another more serious problem: the processor is loaded to 50% when playing the script and does not shut down. Link to comment Share on other sites More sharing options...
Danyfirex Posted March 23, 2016 Share Posted March 23, 2016 Simply add sleep in while. While True If _BASS_ChannelGetPosition($hMusic, $BASS_POS_BYTE) = $song_length Then ExitLoop Sleep(100) WEnd Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
AndreyS Posted March 23, 2016 Author Share Posted March 23, 2016 (edited) I understood why the processor so loaded. Because of cycle. It is, in principle, no problem. But for some reason the script does not complete its work at the end? Can not understand. Yes, yes definitely need a sleep() Edited March 23, 2016 by AndreyS Link to comment Share on other sites More sharing options...
AndreyS Posted March 23, 2016 Author Share Posted March 23, 2016 (edited) I found the reason that the script is not completed. Channel does not reach the full length and stops earlier. What is the problem? Edited March 23, 2016 by AndreyS Link to comment Share on other sites More sharing options...
AndreyS Posted March 23, 2016 Author Share Posted March 23, 2016 Try to please with these two files. The script does not complete its work at the end. What could be the problem? 48-1.mp3 48-2.mp3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now