Re: [PD] [array quantile] explanation

2019-10-30 Thread Miller Puckette
Yep, all your surmises are right.  

cheers
M

On Mon, Oct 28, 2019 at 10:24:58PM +0100, Roman Haefeli wrote:
> On Mon, 2019-10-28 at 13:50 -0700, Miller Puckette wrote:
> > Yes
> 
> Cool.
> 
> >  but not with perfect accuracy.  
> 
> I don't mind.
> 
> > You have to make a histogram of the 
> > samples (choosing some bin size;
> 
> Forgive my ignorance, but how can I create a histogram out of an
> unordered set of samples? Do I just iterate over all samples "manually"
>  and count up the bin depending on in which bin it falls?
> 
> >  that's what limits accuracy) and then
> > array qualtile will do exactly what you're looking for.
> 
> So [array quantile] is meant to be used on a histogram of the raw data,
> as opposed to the raw data directly? That's why it returns something
> that looks like an index, namely the index of the bin of your
> histogram?
> 
> > I use it for instance to do automatic level setting.  I ask for the
> > 90%
> > quamtile of env~ output (in dB) over a period of 10 seconds or so.
> 
> Thanks, this I understand and is very similar to the stuff I'm
> interested in. 
> 
> Roman
> 
> > On Sun, Oct 27, 2019 at 02:46:29PM +0100, Roman Haefeli wrote:
> > > Hi all
> > > 
> > > I am having difficulty understanding the output of [array
> > > quantile].
> > > From the help-file it seems it expects an input between 0 and 1,
> > > and
> > > also the values in the array should be in that range. The output
> > > seems
> > > to be in the range between 0 and  - 1. But what does it
> > > mean?
> > > 
> > > Can I use this somehow to achieve this:
> > > 
> > > I have n samples and input q while 0 < q < 1. I would like to know
> > > the
> > > value x for which q*100 percent samples are smaller than x and (1-
> > > q)*100 percent bigger. 
> > > 
> > > Thanks, 
> > > Roman
> > > 
> > > 
> > >  
> > 
> > 
> > 
> > > ___
> > > Pd-list@lists.iem.at mailing list
> > > UNSUBSCRIBE and account-management -> 
> > > https://lists.puredata.info/listinfo/pd-list
> > 
> > 



> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> https://lists.puredata.info/listinfo/pd-list




___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


[PD] soundtouch~ status quo (was: soundtouch~, slicerec/sliceplay for 64 bit windows?)

2019-10-30 Thread katja
On 10/30/19, Christof Ressi  wrote:
> The problem is actually in the code:
>
> (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16);
>
> This line probably tries to align memory on the stack to 16 bytes boundaries
> for SSE code. The problem is that "ulong" is a typedef for "unsigned long".
> The code assumes that "long" always has the size of a pointer (4 bytes on 32
> bit and 8 bytes on 64 bit), but on Windows it is always 4 bytes, so on 64
> bit you get a size mismatch.

Christof thanks for your analysis and explanation.

To be clear about the current state of soundtouch~: it is a (partial)
port for Pd of Olli Parviainen's SoundTouch library. Olli's project is
probably up to date with the latest platforms but the port was derived
(by me) from an earlier version back in 2011. Ideally soundtouch~ for
pd should be realigned with latest SoundTouch from Olli, and also get
a new build system. Maybe not horribly much work but frankly it can't
be high my todo list. If someone is interested to adopt this project,
take a look at Olli's SoundTouch project and my page describing the
port for pd:

www.surina.net/soundtouch/
www.katjaas.nl/pitchshift/soundtouch~.html

(And to avoid confusion about the other classes mentioned in subject
title: slicerec~/sliceplay will be soon updated by me in the context
of Slice//Jockey).

Katja


>
> A quick and dirty fix: find the relevant "#define" or "typedef" for "ulong"
> and set it to "unsigned long long" for 64 bit Windows:
>
> #ifdef _WIN64
> #define ulong unsigned long long
> #else
> #define ulong unsigned long
> #endif
>
> Please make a bug report to the upstream author.
>
> Christof
> Gesendet: Mittwoch, 30. Oktober 2019 um 00:46 Uhr
> Von: "pat pagano" 
> An: pd-l...@iem.at
> Betreff: Re: [PD] soundtouch~, slicerec/sliceplay for 64 bit windows?
>
> I know that i am flailing with windows makefiles but i was hopeful that from
> trying to compile such an essential external for a few patches i've written
> with it I would learn compiling externals more clearly for pd and of course
> windows
>
> here's what i get:
>
> g++ -m64 -msse -DNT -DPD_LONGINTTYPE=__int64 -DMSW -Wall -Wextra -Wshadow
> -Wint-to-pointer-cast -Winline -Wstrict-aliasing -O3 -ffast-math
> -funroll-loops -fomit-frame-pointer -march=core2 -msse -msse2 -msse3
> -mfpmath=sse -I ./include -c *.cpp
> FIFOSampleBuffer.cpp: In member function 'void
> soundtouch::FIFOSampleBuffer::ensureCapacity(uint)':
> FIFOSampleBuffer.cpp:181:39: error: cast from 'soundtouch::SAMPLETYPE*' {aka
> 'float*'} to 'ulong' {aka 'long unsigned int'} loses precision
> [-fpermissive]
>  temp = (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16);
>^
> FIFOSampleBuffer.cpp:181:71: warning: cast to pointer from integer of
> different size [-Wint-to-pointer-cast]
>  temp = (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16);
>^
> FIRFilter.cpp: In static member function 'static void*
> soundtouch::FIRFilter::operator new(size_t)':
> FIRFilter.cpp:222:39: warning: unused parameter 's' [-Wunused-parameter]
>  void * FIRFilter::operator new(size_t s)
> ~~~^
> RateTransposer.cpp: In static member function 'static void*
> soundtouch::RateTransposer::operator new(size_t)':
> RateTransposer.cpp:109:44: warning: unused parameter 's'
> [-Wunused-parameter]
>  void * RateTransposer::operator new(size_t s)
>  ~~~^
> soundtouch~.cpp: In function 't_int* soundtouch_perform(t_int*)':
> soundtouch~.cpp:91:39: warning: cast to pointer from integer of different
> size [-Wint-to-pointer-cast]
>   t_soundtouch *x = (t_soundtouch *)w[1];// pointer to object
> (struct instance)
>^
> soundtouch~.cpp:92:43: warning: cast to pointer from integer of different
> size [-Wint-to-pointer-cast]
>   t_sample *signalvectorIn = (t_sample*)w[2];   // pointer to input
> signal vector
>^
> soundtouch~.cpp:93:44: warning: cast to pointer from integer of different
> size [-Wint-to-pointer-cast]
>   t_sample *signalvectorOut = (t_sample*)w[3];   // pointer to output
> signal vector
> ^
> soundtouch~.cpp: In function 't_int* soundtouch_perform2(t_int*)':
> soundtouch~.cpp:115:39: warning: cast to pointer from integer of different
> size [-Wint-to-pointer-cast]
>   t_soundtouch *x = (t_soundtouch *)w[1];// pointer to object
> (struct instance)
>^
> soundtouch~.cpp:116:47: warning: cast to pointer from integer of different
> size [-Wint-to-pointer-cast]
>   t_sample *signalvectorInLeft = (t_sample*)w[2];  // pointer to input
> signal vector
>^
> soundtouch~.cpp:117:48: warning: cast to pointer from integer of differen

Re: [PD] soundtouch~, slicerec/sliceplay for 64 bit windows?

2019-10-30 Thread Christof Ressi
> i added the -fpermissive flag and it built :-)

Bad idea. The external will probably crash at runtime. The last error was the 
same problem as before, so just replace “unsigned long“ with “ulong“ (which 
should be unsigned long long on win64).

Actually, one clean solution is to replace “ulong“ with “uintptr_t“ (pointer 
sized unsigned integer)  from “stdint.h“.

Just report this problem to the author and they will fix it.

> Gesendet: Mittwoch, 30. Oktober 2019 um 06:21 Uhr
> Von: "pat pagano" 
> An: "Christof Ressi" 
> Betreff: Re: Re: [PD] soundtouch~, slicerec/sliceplay for 64 bit windows?
>
> i got it
> i added the -fpermissive flag and it built :-)
> 
> 
> On Wed, Oct 30, 2019 at 12:55 AM pat pagano  wrote:
> 
> > i cleaned it up and i got it down to just one error
> >
> > C:\Users\shree\Desktop\KATJA\soundtouch_\soundtouch~\src>make
> > g++ -msse -DPD -DMSW -Werror -Wno-unused -mms-bitfields -Wno-parentheses
> > -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing
> > -fcheck-new -I ./include -c *.cpp
> > sse_optimized.cpp: In member function 'virtual void
> > soundtouch::FIRFilterSSE::setCoefficients(const float*, uint, uint)':
> > sse_optimized.cpp:288:51: error: cast from 'float*' to 'long unsigned int'
> > loses precision [-fpermissive]
> >  filterCoeffsAlign = (float *)(((unsigned long)filterCoeffsUnalign +
> > 15) & (ulong)-16);
> >^~~
> > make: *** [makefile:69: soundtouch~.dll] Error 1
> >
> > can you help me a little more?
> >
> > best
> >
> > Patrick
> >
> >
> > On Tue, Oct 29, 2019 at 9:00 PM Christof Ressi 
> > wrote:
> >
> >> The problem is actually in the code:
> >>
> >> (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16);
> >>
> >> This line probably tries to align memory on the stack to 16 bytes
> >> boundaries for SSE code. The problem is that "ulong" is a typedef for
> >> "unsigned long". The code assumes that "long" always has the size of a
> >> pointer (4 bytes on 32 bit and 8 bytes on 64 bit), but on Windows it is
> >> always 4 bytes, so on 64 bit you get a size mismatch.
> >>
> >> A quick and dirty fix: find the relevant "#define" or "typedef" for
> >> "ulong" and set it to "unsigned long long" for 64 bit Windows:
> >>
> >> #ifdef _WIN64
> >> #define ulong unsigned long long
> >> #else
> >> #define ulong unsigned long
> >> #endif
> >>
> >> Please make a bug report to the upstream author.
> >>
> >> Christof
> >> *Gesendet:* Mittwoch, 30. Oktober 2019 um 00:46 Uhr
> >> *Von:* "pat pagano" 
> >> *An:* pd-l...@iem.at
> >> *Betreff:* Re: [PD] soundtouch~, slicerec/sliceplay for 64 bit windows?
> >>
> >> I know that i am flailing with windows makefiles but i was hopeful that
> >> from trying to compile such an essential external for a few patches i've
> >> written with it I would learn compiling externals more clearly for pd and
> >> of course windows
> >>
> >> here's what i get:
> >>
> >> g++ -m64 -msse -DNT -DPD_LONGINTTYPE=__int64 -DMSW -Wall -Wextra -Wshadow
> >> -Wint-to-pointer-cast -Winline -Wstrict-aliasing -O3 -ffast-math
> >> -funroll-loops -fomit-frame-pointer -march=core2 -msse -msse2 -msse3
> >> -mfpmath=sse -I ./include -c *.cpp
> >> FIFOSampleBuffer.cpp: In member function 'void
> >> soundtouch::FIFOSampleBuffer::ensureCapacity(uint)':
> >> FIFOSampleBuffer.cpp:181:39: error: cast from 'soundtouch::SAMPLETYPE*'
> >> {aka 'float*'} to 'ulong' {aka 'long unsigned int'} loses precision
> >> [-fpermissive]
> >>  temp = (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16);
> >>^
> >> FIFOSampleBuffer.cpp:181:71: warning: cast to pointer from integer of
> >> different size [-Wint-to-pointer-cast]
> >>  temp = (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16);
> >>^
> >> FIRFilter.cpp: In static member function 'static void*
> >> soundtouch::FIRFilter::operator new(size_t)':
> >> FIRFilter.cpp:222:39: warning: unused parameter 's' [-Wunused-parameter]
> >>  void * FIRFilter::operator new(size_t s)
> >> ~~~^
> >> RateTransposer.cpp: In static member function 'static void*
> >> soundtouch::RateTransposer::operator new(size_t)':
> >> RateTransposer.cpp:109:44: warning: unused parameter 's'
> >> [-Wunused-parameter]
> >>  void * RateTransposer::operator new(size_t s)
> >>  ~~~^
> >> soundtouch~.cpp: In function 't_int* soundtouch_perform(t_int*)':
> >> soundtouch~.cpp:91:39: warning: cast to pointer from integer of different
> >> size [-Wint-to-pointer-cast]
> >>   t_soundtouch *x = (t_soundtouch *)w[1];// pointer to object
> >> (struct instance)
> >>^
> >> soundtouch~.cpp:92:43: warning: cast to pointer from integer of different
> >> size [-Wint-to-pointer-cast]
> >>   t_sample *signalvectorIn = (t_sample*)w[2];