Generating sound signals

205 views
Skip to first unread message

Alexandru

unread,
Sep 10, 2021, 8:48:42 AM9/10/21
to
Hi,

After searching the web I found the Tcl package SNACK https://www.speech.kth.se/snack/download.html, that I could use the generate a sound signal (sinus shaped and wanted frequency).

On the other side, the project seems to be dead.
Are there other packages out there for sound signal generation.

Also interesting would be to generate superposed sound signals.

Many thanks
Alex

Scott Pitcher

unread,
Sep 10, 2021, 8:28:10 PM9/10/21
to
On Friday, September 10, 2021 at 10:48:42 PM UTC+10, Alexandru wrote:
> After searching the web I found the Tcl package SNACK https://www.speech.kth.se/snack/download.html, that I could use the generate a sound signal (sinus shaped and wanted frequency).
>
> On the other side, the project seems to be dead.
> Are there other packages out there for sound signal generation.

I used Snack recently for making a "Pitch Pipe" Android app for tuning my guitar. It certainly works and ought to do what you want.

Alexandru

unread,
Sep 11, 2021, 6:37:38 AM9/11/21
to
Thanks for the input.
That's good news.
Alexandru

Alexandru

unread,
Sep 20, 2021, 7:40:18 AM9/20/21
to
scotty...@gmail.com schrieb am Samstag, 11. September 2021 um 02:28:10 UTC+2:
I tried to run snack on Windows 10 64bit and it fails with

couldn't load library "C:/Tcl/lib/snack2.2.10/libsnack.dll": Bad exe format. Possibly a 32/64-bit mismatch.

Does this mean I must compile from source?

Scott Pitcher

unread,
Sep 20, 2021, 4:58:51 PM9/20/21
to
On Monday, September 20, 2021 at 9:40:18 PM UTC+10, Alexandru wrote:
> I tried to run snack on Windows 10 64bit and it fails with
>
> couldn't load library "C:/Tcl/lib/snack2.2.10/libsnack.dll": Bad exe format. Possibly a 32/64-bit mismatch.

Ok yes that looks to be true. I'm working on Windows 7 and it looks like 32 bit.

(bin) 2 % parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(engine) = Tcl
tcl_platform(machine) = intel
tcl_platform(os) = Windows NT
tcl_platform(osVersion) = 6.1
tcl_platform(pathSeparator) = ;
tcl_platform(platform) = windows
tcl_platform(pointerSize) = 4
tcl_platform(threaded) = 1
tcl_platform(user) = scottyw
tcl_platform(wordSize) = 4
(bin) 3 %

Scott Pitcher

unread,
Sep 20, 2021, 6:08:57 PM9/20/21
to
The tcl/tk on my Linux system is 64 bit and Snack is available.

scotty@workshoppc:~$ wish
% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(engine) = Tcl
tcl_platform(machine) = x86_64
tcl_platform(os) = Linux
tcl_platform(osVersion) = 4.20.17-042017-generic
tcl_platform(pathSeparator) = :
tcl_platform(platform) = unix
tcl_platform(pointerSize) = 8
tcl_platform(threaded) = 1
tcl_platform(user) = scotty
tcl_platform(wordSize) = 8
% package require snack
2.2
%

Over on Windows I'm building a 64 bit version of TclTk 8.6.10 using mingw64. I've got the snack source so I'll see if I can build and run it with a 64 bit wish.

Ralf Fassel

unread,
Sep 21, 2021, 12:10:00 PM9/21/21
to
* Scott Pitcher <scotty...@gmail.com>
| Over on Windows I'm building a 64 bit version of TclTk 8.6.10 using
| mingw64. I've got the snack source so I'll see if I can build and run
| it with a 64 bit wish.

We're building snack on Windows for both 32bit and 64bit,
with msys/configure and MSVC 2019. We fiddle with the generated
Makefiles a bit (replace -I/c/some/path by -Ic:/some/path, -ltclstub by
tclstub.lib etc via sed), so it should be feasible with mingw, too.

R'

Scott Pitcher

unread,
Sep 21, 2021, 8:06:14 PM9/21/21
to
On Wednesday, September 22, 2021 at 2:10:00 AM UTC+10, Ralf Fassel wrote:
> We're building snack on Windows for both 32bit and 64bit,
> with msys/configure and MSVC 2019. We fiddle with the generated
> Makefiles a bit (replace -I/c/some/path by -Ic:/some/path, -ltclstub by
> tclstub.lib etc via sed), so it should be feasible with mingw, too.

Ah, thanks Ralf. That's good to know. I had a couple of problems building that I had to patch around
1. KSDATAFORMAT_SUBTYPE_PCM redeclared in win/jkAudIO_win.c.
2. roundf() defined locally in generic/jkFormatMP3.c
3. Link errors with Tcl_SeekOld and Tcl_TellOld. These seem to be #undefined in Tcl 8.6 so I used the same definition as for TCL_MINOR_VERSION < 4 in jSound.h.

So then it would build although with plenty of warnings. But then it seg faults in jkFormatMP3.c. But it does this for both the 32 and 64 bit builds.

Thread 1 received signal SIGSEGV, Segmentation fault.
layer3_frame (len=<optimized out>, header=0x22f7b0, ext=<optimized out>)
at ../win/../generic/jkFormatMP3.c:2873
2873 for (ch=0;ch<ext->nch;ch++) requantize_mono(ext, gr,ch,&info,header);
1: x/3i $pc
=> 0x39a45a0 <ReadMP3Samples+7904>: movl $0x0,(%rax)
0x39a45a6 <ReadMP3Samples+7910>: add $0x4,%rax
0x39a45aa <ReadMP3Samples+7914>: jmp 0x39a45a0 <ReadMP3Samples+7904>
Value can't be converted to integer.
(gdb) backtrace full no-filter
#0 layer3_frame (len=<optimized out>, header=0x22f7b0, ext=<optimized out>)
at ../win/../generic/jkFormatMP3.c:2873

Now, there was a warning from gcc when compiling this module:

gcc -g -O2 -O2 -fomit-frame-pointer -DHAVE_STDINT_H -IC:/Users/scottyw/Desktop/src/tcltk/tcltk-build/tcl8.6.9/generic -I/c/Users/scottyw/Desktop/src/tcltk/tcltk-build/tk8.6.9/generic -I/c/Users/scottyw/Desktop/src/tcltk/tcltk-build/tk8.6.9/xlib -I/mingw/dx6/include -I../win/../generic -DWIN -DUSE_TCL_STUBS -DUSE_TK_STUBS -DBUILD_snack -DTCL_81_API -c -o jkFormatMP3.o ../win/../generic/jkFormatMP3.c
../win/../generic/jkFormatMP3.c: In function 'requantize_mono':
../win/../generic/jkFormatMP3.c:774:26: warning: iteration 18 invokes undefined behavior [-Waggressive-loop-optimizations]
774 | ext->xr[ch][0][l]=FRAS2(ext->is[ch][l],a);
| ^
../win/../generic/jkFormatMP3.c:773:13: note: within this loop
773 | while (l<36) {
| ^

I decided to remove the -O2 optimisation from the Makefile, and I rebuilt the 32 bit version, and now it runs. The test I am using is a desktop stopwatch I use for metering our tasks in the workshop. It plays an MP3 at the alarm time and I use snack for this.

I'm still having a problem with a seg fault at the same place in the 64 bit version. I've turned off optimisaton with -O0 but I'm not sure this is working:

Thread 1 received signal SIGSEGV, Segmentation fault.
layer3_frame (len=<optimized out>, header=0x22f7b0, ext=<optimized out>)
at ../win/../generic/jkFormatMP3.c:2873
warning: Source file is more recent than executable.
2873 if (header->mode!=1 || (header->mode==1 && header->mode_extension==0))
1: x/3i $pc
=> 0x3ab45a0 <ReadMP3Samples+7904>: movl $0x0,(%rax)
0x3ab45a6 <ReadMP3Samples+7910>: add $0x4,%rax
0x3ab45aa <ReadMP3Samples+7914>: jmp 0x3ab45a0 <ReadMP3Samples+7904>
(gdb) backtrace full no-filter
#0 layer3_frame (len=<optimized out>, header=0x22f7b0, ext=<optimized out>)
at ../win/../generic/jkFormatMP3.c:2873
rest = <optimized out>
gr = <optimized out>
tmp = <optimized out>
fs = <optimized out>
hsize = <optimized out>
ch = 0
sb = <optimized out>
i = <optimized out>
mean_frame_size = <optimized out>
bitrate = <optimized out>
ssize = <optimized out>
cnt = <optimized out>
info = {main_data_begin = 15, scfsi = {{0, 0, 0, 0}, {0, 0, 0, 0}},
part2_3_length = {{940, 0}, {0, 0}}, big_values = {{107, 0}, {0,
0}}, global_gain = {{177, 0}, {0, 0}}, scalefac_compress = {{
223, 0}, {0, 0}}, window_switching_flag = {{1, 0}, {0, 0}},
block_type = {{3, 0}, {0, 0}}, mixed_block_flag = {{0, 0}, {0, 0}},
table_select = {{{15, 6, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 0, 0}}},
subblock_gain = {{{0, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 0, 0}}},
region0_count = {{0, 0}, {0, 0}}, region1_count = {{0, 0}, {0, 0}},
preflag = {{0, 0}, {0, 0}}, scalefac_scale = {{1, 0}, {0, 0}},
count1table_select = {{0, 0}, {0, 0}}, error = {0, 0}}
gr = <optimized out>
ch = <optimized out>
sb = <optimized out>
i = <optimized out>
tmp = <optimized out>
mean_frame_size = <optimized out>
bitrate = <optimized out>
fs = <optimized out>
hsize = <optimized out>
ssize = <optimized out>
cnt = <optimized out>
rest = <optimized out>
win_type = <optimized out>
l = <optimized out>
l = <optimized out>

Scott Pitcher

unread,
Sep 21, 2021, 8:15:37 PM9/21/21
to
Sorry, I'll correct that. After removing the old library from the Tcl/lib directory (I'd mistakenly renamed it with -old suffix but Tk was still picking it up), I ran my test and it passes. It's plays an MP3 file. So after turning off optimisation I am able to build and run both 32 and 64 bit builds. More work needs to be done to work out what level of optimisation will work and why, but it does work. I havn't tried Snack's tests yet either.

Alexandru would you like a copy of the -64 bit library to test?

Alexandru

unread,
Sep 21, 2021, 8:16:56 PM9/21/21
to
scotty...@gmail.com schrieb am Mittwoch, 22. September 2021 um 02:15:37 UTC+2:
> Sorry, I'll correct that. After removing the old library from the Tcl/lib directory (I'd mistakenly renamed it with -old suffix but Tk was still picking it up), I ran my test and it passes. It's plays an MP3 file. So after turning off optimisation I am able to build and run both 32 and 64 bit builds. More work needs to be done to work out what level of optimisation will work and why, but it does work. I havn't tried Snack's tests yet either.
>
> Alexandru would you like a copy of the -64 bit library to test?
Hi Scotty,

of course. Thank you!

Scott Pitcher

unread,
Sep 21, 2021, 9:35:00 PM9/21/21
to
I've put a copy of the 64 bit binary library on my Google Drive as snack2.2.10-Windows-amd64-debug-no_opt.tar.gz.

It's compiled without optimisation and with debug symbols.

Link: https://drive.google.com/file/d/1xuLFPS1sR-vrwMyRq3H_bYwLB3Sk2HCJ/view?usp=sharing

Alexandru

unread,
Sep 22, 2021, 1:15:49 AM9/22/21
to
Works for me!
I tested this:

set f [snack::filter generator 440.0 30000 0.0 sine 8000]
set s [snack::sound]
$s play -filter $f

Ralf Fassel

unread,
Sep 22, 2021, 4:33:20 AM9/22/21
to
* Scott Pitcher <scotty...@gmail.com>
| On Wednesday, September 22, 2021 at 2:10:00 AM UTC+10, Ralf Fassel wrote:
| > We're building snack on Windows for both 32bit and 64bit,
| > with msys/configure and MSVC 2019. We fiddle with the generated
| > Makefiles a bit (replace -I/c/some/path by -Ic:/some/path, -ltclstub by
| > tclstub.lib etc via sed), so it should be feasible with mingw, too.
>
| Ah, thanks Ralf. That's good to know. I had a couple of problems
| building that I had to patch around
--<snip-snip>--
| 3. Link errors with Tcl_SeekOld and Tcl_TellOld. These seem to be
| #undefined in Tcl 8.6 so I used the same definition as for
| TCL_MINOR_VERSION < 4 in jSound.h.

Ah, yes, now that you mention it...

I regularly patch the TCL sources to re-enable Tcl_TellOld and Tcl_SeekOld:

--- tcl8.6.11/generic/tclDecls.h.orig 2016-03-01 02:59:21.000000000 +0100
+++ tcl8.6.11/generic/tclDecls.h 2016-03-01 11:06:03.388180928 +0100
@@ -3866,8 +3866,10 @@
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT

+#if 0
#undef Tcl_SeekOld
#undef Tcl_TellOld
+#endif

#undef Tcl_PkgPresent
#define Tcl_PkgPresent(interp, name, version, exact) \

Diff finished. Wed Aug 16 11:27:00 2017

| So then it would build although with plenty of warnings. But then it
| seg faults in jkFormatMP3.c. But it does this for both the 32 and 64
| bit builds.

*Blush* since we don't require mp3 in snack, we disable mp3 (for the
exact problem you encountered) by removing it from the list of file
formats.

Plus another patch which also resulted in SEGVs:

*** snack2.2.10/generic/jkSoundEngine.c~ Wed Dec 1 15:23:46 2004
--- snack2.2.10/generic/jkSoundEngine.c Tue Jun 14 11:56:19 2005
***************
*** 1694,1700 ****

if (soundQueue != NULL) {
for (p = soundQueue; p != NULL && p->sound != s; p = p->next);
! if (p->sound == s) {
n = p->startPos + p->nWritten;
}
}
--- 1694,1700 ----

if (soundQueue != NULL) {
for (p = soundQueue; p != NULL && p->sound != s; p = p->next);
! if (p && p->sound == s) {
n = p->startPos + p->nWritten;
}
}

HTH
R'

Scott Pitcher

unread,
Sep 22, 2021, 7:12:30 AM9/22/21
to
On Wednesday, September 22, 2021 at 6:33:20 PM UTC+10, Ralf Fassel wrote:

> Plus another patch which also resulted in SEGVs:
>
> *** snack2.2.10/generic/jkSoundEngine.c~ Wed Dec 1 15:23:46 2004

Thanks for the additional patch :).

I might place the code on Github where it can be kept "alive".

Yann-Erwan Trévilly

unread,
Jan 5, 2023, 5:27:19 AMJan 5
to
> > Alexandru would you like a copy of the -64 bit library to test?
> Hi Scotty,
>
> of course. Thank you!

Hi Scotty,
I'm building a version of Wavesurfer for bioacoustics in 32bits. But I would like a 64-bit version and I need snack: is your patch for the 64-bit version of snack still available? The link no longer works. It would be great...
Yann

Scott Pitcher

unread,
Jan 6, 2023, 5:25:24 AMJan 6
to
Hi Yann,

I've uploaded it to Github. Please see if any of the binaries on this page help you: https://github.com/scottypitcher/tcl-snack/releases

Kind regards,
Scott

Paul Obermeier

unread,
Jan 6, 2023, 4:57:03 PMJan 6
to
Hi Scott,

I'm trying to include your Snack version into my BAWT framework.

It compiles and runs fine on Windows 11 using MinGW/gcc in 32-bit and 64-bit.
(I had to replace the "mkdir" call with "mkdir -p" in Makefile.in).

When compiling on Linux with default configure options, I get the following error when starting snack:
"Unable to open mixer /dev/mixer"
and the following error when trying to run demo generator.tcl:
"Could not gain access to /dev/sound/dsp for writing"

When configuring with "--enable-alsa" I get the following error when starting snack:
undefined symbol: _snd_pcm_mmap_hw_ptr
while executing "load /opt/Tcl/lib/snack2.2.11/libsnack.so"

Which configure option are you using and which Linux distribution does it run for you?

Thanks,
Paul

Scott Pitcher

unread,
Jan 6, 2023, 5:45:39 PMJan 6
to
On Saturday, January 7, 2023 at 8:57:03 AM UTC+11, Paul Obermeier wrote:
.....
> Hi Scott,
>
> I'm trying to include your Snack version into my BAWT framework.
>
> It compiles and runs fine on Windows 11 using MinGW/gcc in 32-bit and 64-bit.
> (I had to replace the "mkdir" call with "mkdir -p" in Makefile.in).
>
> When compiling on Linux with default configure options, I get the following error when starting snack:
> "Unable to open mixer /dev/mixer"
> and the following error when trying to run demo generator.tcl:
> "Could not gain access to /dev/sound/dsp for writing"
>
> When configuring with "--enable-alsa" I get the following error when starting snack:
> undefined symbol: _snd_pcm_mmap_hw_ptr
> while executing "load /opt/Tcl/lib/snack2.2.11/libsnack.so"
>
> Which configure option are you using and which Linux distribution does it run for you?
>
> Thanks,
> Paul

Hi Paul,
My tcl-snack/build-x86_64/config.log shows:

| This file contains any messages produced by compilers while
| running configure, to aid debugging if configure makes a mistake.
|
| It was created by configure, which was
| generated by GNU Autoconf 2.69. Invocation command line was
|
| $ ../unix/configure --prefix=/home/scotty/Tcl8.6.9-x86_64 --srcdir=../unix

I'm using the scripts I placed in tcl-snack/devtools, specifically myconfigure.sh. That script did work on both Windows (MINGW) and Linux when I built the binaries.

I'm running Ubuntu 18.04.1 here:
| scotty@officepc:~$ uname -a
| Linux officepc.svpts 5.4.0-132-lowlatency #148~18.04.1-Ubuntu SMP PREEMPT Mon Oct 24 21:15:00 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

I use my own builds of Tcl for testing in my home directory and I build and install Snack there, building both 32 and 64 bit in each case. I just reran the snack tests/all.tcl test (note, the ex1.wav file I had to copy from over in the snack demos/.... directory into tests/ to get it run cleanly:

| scotty@officepc:~/src/tcltk/tcl-snack/tests$ cp ../demos/tcl/ex1.wav ./
| scotty@officepc:~/src/tcltk/tcl-snack/tests$ ~/Tcl8.6.9-x86_64/bin/tclsh8.6 all.tcl
| Tcl 8.6.9 tests running in interp: /home/scotty/Tcl8.6.9-x86_64/bin/tclsh8.6
| Tests running in working dir: /home/scotty/src/tcltk/tcl-snack/tests
| Only running tests that match: *
| Skipping test files that match: l.*.test
| Only sourcing test files that match: *.test
| Tests began at Sat Jan 07 09:33:13 AEDT 2023
| audio.test
| cget.test
| concat.test
| conf.test
| convert.test
| copy.test
| crop.test
| cut.test
| data.test
| dbpower.test
| fileio.test
| filter.test
| formant.test
| inflush.test
| insert.test
| length.test
| maxmin.test
| mixer.test
| pitch.test
|
|
| ==== pitch-1.3 pitch command FAILED
| ==== Contents of test case:
|
| set tcl_precision 5
| set s [snack::sound snd -load ex1.wav]
| set res [$s pitch -method ESPS]
| $s destroy
| set res
|
| ---- Result was:
| {0.0 0.0 0.0 0.7046} {0.0 0.0 773.7 0.65552} {0.0 0.0 818.08 0.24061} {0.0 0.0 813.13 0.56787} {0.0 0.0 808.39 0.51307} {0.0 0.0 826.01 0.49327} {0.0 0.0 856.56 0.9469} {0.0 0.0 851.72 0.0} {0.0 0.0 869.15 0.48861} {0.0 0.0 842.57 0.39768} {0.0 0.0 839.14 0.4009} {0.0 0.0 820.39 0.81465} {0.0 0.0 833.47 0.95806} {0.0 0.0 855.33 0.89539} {0.0 0.0 852.97 0.28335} {0.0 0.0 889.07 0.59169} {0.0 0.0 1070.5 0.68884} {0.0 0.0 878.41 0.5143} {0.0 0.0 892.74 0.3997} {0.0 0.0 873.53 0.68623} {0.0 0.0 965.13 0.57252} {0.0 0.0 882.69 0.49351} {0.0 0.0 1193.0 0.70511} {209.81 1.0 3304.3 0.88756} {162.78 1.0 3660.9 0.99115} {161.92 1.0 3512.7 0.99646} {158.92 1.0 3547.9 0.99354} {155.91 1.0 3468.7 0.98505} {149.48 1.0 3285.3 0.99364} {143.31 1.0 3008.2 0.98736} {133.77 1.0 2823.7 0.94805} {126.48 1.0 2640.8 0.98759} {119.94 1.0 2333.7 0.9852} {112.98 1.0 2040.5 0.95218} {109.81 1.0 2121.6 0.9571} {107.68 1.0 2418.1 0.92161} {106.6 1.0 2507.3 0.95998} {105.57 1.0 2478.0 0.95695} {105.43 1.0 2671.9 0.96458} {106.74 1.0 2706.6 0.98918} {109.0 1.0 2755.4 0.99448} {111.84 1.0 2717.5 0.97564} {115.73 1.0 2277.5 0.87201} {99.183 1.0 924.36 0.60726} {120.34 1.0 859.79 0.84981} {150.88 1.0 2136.3 0.93803} {136.25 1.0 2838.1 0.98336} {141.73 1.0 2877.0 0.99704} {145.06 1.0 2894.6 0.98906} {146.54 1.0 2749.1 0.98797} {149.82 1.0 2699.5 0.94096} {149.23 1.0 2838.4 0.98879} {146.53 1.0 2630.6 0.95378} {141.86 1.0 2181.0 0.97326} {133.37 1.0 1888.3 0.85003} {124.99 1.0 1660.0 0.94212} {117.97 1.0 1443.6 0.96375} {109.74 1.0 1091.7 0.96917} {103.63 1.0 915.75 0.92499} {111.49 1.0 853.13 0.69573} {107.37 1.0 786.42 0.86455} {93.37 1.0 815.44 0.81332} {123.3 1.0 804.05 0.61468} {84.033 1.0 762.98 0.74945} {121.1 1.0 725.91 0.5574} {114.08 1.0 700.22 0.82347} {101.78 1.0 704.95 0.57994} {103.43 1.0 695.87 0.75774} {101.42 1.0 699.81 0.79472} {105.86 1.0 714.47 0.70127} {0.0 0.0 745.7 0.828} {0.0 0.0 736.31 0.64289} {0.0 0.0 696.35 0.40449} {0.0 0.0 684.65 0.44551} {0.0 0.0 639.58 0.38997} {0.0 0.0 561.77 0.0} {0.0 0.0 627.65 0.34976} {0.0 0.0 717.62 0.38937} {0.0 0.0 748.27 0.41932} {0.0 0.0 750.33 0.86962} {0.0 0.0 783.3 0.82826} {0.0 0.0 761.05 0.20038} {0.0 0.0 809.51 0.35076} {0.0 0.0 831.97 0.7714} {0.0 0.0 872.22 0.67117} {0.0 0.0 826.62 0.6413} {0.0 0.0 717.3 0.0} {0.0 0.0 723.3 0.54415} {0.0 0.0 751.75 0.33728} {0.0 0.0 818.03 0.31209} {0.0 0.0 837.29 0.4341} {0.0 0.0 849.53 0.3289} {0.0 0.0 862.33 0.28854} {0.0 0.0 845.65 0.68362} {0.0 0.0 868.25 0.74526}
| ---- Result should have been (exact matching):
| {0.0 0.0 0.0 0.7046} {0.0 0.0 773.75 0.65552} {0.0 0.0 818.19 0.24061} {0.0 0.0 813.11 0.56787} {0.0 0.0 808.38 0.51307} {0.0 0.0 826.19 0.49327} {0.0 0.0 856.39 0.9469} {0.0 0.0 851.94 0.0} {0.0 0.0 869.07 0.48861} {0.0 0.0 842.5 0.39768} {0.0 0.0 839.18 0.4009} {0.0 0.0 820.35 0.81465} {0.0 0.0 833.41 0.95806} {0.0 0.0 855.43 0.89539} {0.0 0.0 853.1 0.28335} {0.0 0.0 889.35 0.59169} {0.0 0.0 1070.4 0.68884} {0.0 0.0 878.07 0.5143} {0.0 0.0 893.05 0.3997} {0.0 0.0 873.35 0.68623} {0.0 0.0 965.28 0.57252} {0.0 0.0 882.13 0.49351} {0.0 0.0 1196.0 0.70511} {209.81 1.0 3310.1 0.88756} {162.78 1.0 3659.8 0.99115} {161.92 1.0 3512.8 0.99646} {158.92 1.0 3547.8 0.99354} {155.91 1.0 3468.3 0.98505} {149.48 1.0 3284.6 0.99364} {143.31 1.0 3007.4 0.98736} {133.77 1.0 2823.2 0.94805} {126.48 1.0 2640.0 0.98759} {119.94 1.0 2332.5 0.9852} {112.98 1.0 2040.0 0.95218} {109.81 1.0 2122.5 0.9571} {107.68 1.0 2418.8 0.92161} {106.6 1.0 2507.1 0.95998} {105.57 1.0 2478.7 0.95695} {105.43 1.0 2671.9 0.96458} {106.74 1.0 2706.4 0.98918} {109.0 1.0 2755.5 0.99448} {111.84 1.0 2716.9 0.97564} {115.73 1.0 2274.5 0.87201} {99.183 1.0 920.17 0.60726} {120.34 1.0 860.54 0.84981} {150.88 1.0 2140.9 0.93803} {136.25 1.0 2838.7 0.98336} {141.73 1.0 2877.0 0.99704} {145.06 1.0 2894.6 0.98906} {146.54 1.0 2748.1 0.98797} {149.82 1.0 2700.2 0.94096} {149.23 1.0 2838.5 0.98879} {146.53 1.0 2629.4 0.95378} {141.86 1.0 2179.6 0.97326} {133.37 1.0 1887.6 0.85003} {124.99 1.0 1659.4 0.94212} {117.97 1.0 1442.7 0.96375} {109.74 1.0 1090.7 0.96917} {103.63 1.0 915.58 0.92499} {111.49 1.0 852.97 0.69573} {107.37 1.0 786.45 0.86455} {93.37 1.0 815.31 0.81332} {123.3 1.0 804.19 0.61468} {84.033 1.0 762.64 0.74945} {121.1 1.0 725.97 0.5574} {114.08 1.0 700.18 0.82347} {101.78 1.0 704.91 0.57994} {103.43 1.0 695.82 0.75774} {101.42 1.0 699.76 0.79472} {105.86 1.0 714.6 0.70127} {0.0 0.0 745.64 0.828} {0.0 0.0 736.29 0.64289} {0.0 0.0 696.31 0.40449} {0.0 0.0 684.55 0.44551} {0.0 0.0 639.39 0.38997} {0.0 0.0 561.58 0.0} {0.0 0.0 628.03 0.34976} {0.0 0.0 717.81 0.38937} {0.0 0.0 748.32 0.41932} {0.0 0.0 750.33 0.86962} {0.0 0.0 783.32 0.82826} {0.0 0.0 761.07 0.20038} {0.0 0.0 809.66 0.35076} {0.0 0.0 831.98 0.7714} {0.0 0.0 872.36 0.67117} {0.0 0.0 826.35 0.6413} {0.0 0.0 717.04 0.0} {0.0 0.0 723.39 0.54415} {0.0 0.0 751.84 0.33728} {0.0 0.0 818.29 0.31209} {0.0 0.0 837.27 0.4341} {0.0 0.0 849.58 0.3289} {0.0 0.0 862.31 0.28854} {0.0 0.0 845.67 0.68362} {0.0 0.0 868.24 0.74526}
| ==== pitch-1.3 FAILED
|
|
| Segmentation fault (core dumped)
| scotty@officepc:~/src/tcltk/tcl-snack/tests$

That last test seems to always fails on Linux due to small variations in the result.

For building Tcl and Tk I use a similar set of scripts. I think that's where I crafted the snack devtools scripts from. They are stock builds but just put the results into different directories for X86_64, AMD, debug etc, so I can run tests against each easily.

Kind regards,
Scott

Ralf Fassel

unread,
Jan 9, 2023, 10:50:13 AMJan 9
to
* Paul Obermeier <ober...@poSoft.de>
>
| When configuring with "--enable-alsa" I get the following error when starting snack:
| undefined symbol: _snd_pcm_mmap_hw_ptr
| while executing "load /opt/Tcl/lib/snack2.2.11/libsnack.so"
>
| Which configure option are you using and which Linux distribution does it run for you?

FWIW,
we use snack2.2.10 (without MP3 which we don't need) on OpenSuse 15.4
and Debian 11.

Here are the patches that we apply to snack2.2.10:

==================================================


--- snack2.2.10/generic/jkSoundEngine.c.orig
+++ snack2.2.10/generic/jkSoundEngine.c
@@ -1694,7 +1694,7 @@

if (soundQueue != NULL) {
for (p = soundQueue; p != NULL && p->sound != s; p = p->next);
- if (p->sound == s) {
+ if (p && p->sound == s) {
n = p->startPos + p->nWritten;
}
}

==================================================


# https://bugs.gentoo.org/show_bug.cgi?id=226137
# + double-close-protection
--- snack2.2.10/unix/jkAudIO_alsa.c.orig
+++ snack2.2.10/unix/jkAudIO_alsa.c
@@ -49,6 +49,8 @@

static int minNumChan = 1;

+static snd_pcm_uframes_t hw_bufsize = 0;
+
int
SnackAudioOpen(ADesc *A, Tcl_Interp *interp, char *device, int mode, int freq,
int nchannels, int encoding)
@@ -135,6 +137,9 @@
Tcl_AppendResult(interp, "Failed setting HW params.", NULL);
return TCL_ERROR;
}
+
+ snd_pcm_hw_params_get_buffer_size (hw_params, &hw_bufsize);
+
snd_pcm_hw_params_free(hw_params);
snd_pcm_prepare(A->handle);
if (A->mode == RECORD) {
@@ -155,9 +160,11 @@
{
if (A->debug > 1) Snack_WriteLog(" Enter SnackAudioClose\n");

- snd_pcm_drop(A->handle);
- snd_pcm_close(A->handle);
-
+ if (A->handle) {
+ snd_pcm_drop(A->handle);
+ snd_pcm_close(A->handle);
+ A->handle = NULL;
+ }
if (A->debug > 1) Snack_WriteLog(" Exit SnackAudioClose\n");

return(0);
@@ -202,6 +209,8 @@
int i;
static char buf[64];

+ return;
+
if (A->debug > 1) Snack_WriteLog(" Enter SnackAudioPost\n");

for (i = 0; i < 1000; i++) {
@@ -267,12 +276,14 @@
long
SnackAudioPlayed(ADesc *A)
{
- long avail = _snd_pcm_mmap_hw_ptr(A->handle);
+ // FIX Here, _snd_pcm_mmap_hw_ptr is deprecated in new alsalib
+ long played = A->nWritten - (hw_bufsize - SnackAudioWriteable(A));
+ // long avail = _snd_pcm_mmap_hw_ptr(A->handle);

- if (avail < 0)
- avail = 0;
+ if (played < 0)
+ return 0;

- return (avail+A->nPlayed);
+ return (played);
}

void


==================================================

HTH
R'

Paul Obermeier

unread,
Jan 9, 2023, 2:17:17 PMJan 9
to
Hi Ralf,

thanks for the patches, which I detected yesterday.
I have tested the patches today successfully on Debian 10, Ubuntu 20 and SUSE 15.1.

Paul
Reply all
Reply to author
Forward
0 new messages