Re: [fpc-pascal] for loop vs while loop

2017-02-02 Thread Lars
On Wed, February 1, 2017 4:49 am, Graeme Geldenhuys wrote:
> Hi,
>
>
> Just curious (been in a discussion with somebody else). Is there a
> performance difference between a FOR loop and a WHILE loop?
>
> Not sure if it will make a difference, but the usage is with three
> nested loops, iterating over some 300,000 plus data points in total.
>
>
> Regards,
> Graeme
>

Don't forget Repeat Until...

Simply look at the assembler code generated (a big sin)

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] for loop vs while loop

2017-02-02 Thread DaWorm
On Thu, Feb 2, 2017 at 4:01 AM, Mark Morgan Lloyd <
markmll.fpc-pas...@telemetry.co.uk> wrote:

>
> It's interesting that the real (wallclock) and user times are consistently
> in a different sequence. /If/ the user time is to be believed, there's a
> very small advantage to counting down even if the sequence you want is
> ascending (i.e. test3) rather than simply counting up.


Not looking at the assembly either, but I'd assume it's because you can do
a simple test for zero in the count down case, and have to do a compare
against a value and then test the result on count up, which probably takes
an extra instruction or two.  The optimization can sometimes convert
everything to count down as part of the setup of the loop (I know in Delphi
you'd sometimes see loops run the other way in the debugger when there was
no behavioral change in function).  I guess since in your examples the
final contents of the a variable after the loop exits depends on direction,
then it couldn't do this for the count up loops.  Maybe try again with
Inc(a) in the body?

Jeff.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc and voip ?

2017-02-02 Thread José Mejuto

El 02/02/2017 a las 18:25, fredvs escribió:


- Opus: only one sample-rate: 48k (easier for mixing + DSP)


AbbreviationAudio bandwidth Effective sample rate
NB (narrowband)   4 kHz 8 kHz
MB (medium-band)  6 kHz12 kHz
WB (wideband) 8 kHz16 kHz
SWB (super-wideband) 12 kHz24 kHz
FB (fullband)20 kHz48 kHz

And please move opus related to fpc-other.

--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc and voip ?

2017-02-02 Thread fredvs
> Anyway mp3 technology is surpassed a lot by others. 

Hum, first shots with Opus:

- For same quality, size of Opus is 20 % smaller than mp3.
- You may encode in different modes (voice, audio,..).
-  Tag is much easier to access/edit than mp3.
- Opus: only one sample-rate: 48k (easier for mixing + DSP)
- Encoding high quality audio = +- quality of wav.
- Up to 256 channels (!)
- In same library, decoder + encoder (wow).
- Free and open source, without problems of maybe copyright expires.

Fre;D




-
Many thanks ;-)
--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/fpc-and-voip-tp5727307p5727561.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc and voip ?

2017-02-02 Thread fredvs
> Hi freedvs, does it mean with UOS I can create an audio streaming server
via HTTP?.

If you convert your audio file into opus-file, no problem.

But for live audio streaming server... 

I take a little break and then, it is the next battle.
I can already encode the incoming pcm into Opus file.

But how to do real internet steaming (voip or web-radio), I must study
HTTP-server.
It will be difficult for me to test because I do not have easy web access.

So, any infos, advices, how-to will be very welcome.

Fre;D



-
Many thanks ;-)
--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/fpc-and-voip-tp5727307p5727560.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpc and voip ?

2017-02-02 Thread José Mejuto

El 02/02/2017 a las 16:32, Santiago A. escribió:

El 17/01/2017 a las 16:48, José Mejuto escribió:


Maybe you may think in Opus http://opus-codec.org/ as it is open,
royalty free (mp3 is not free, you must pay royalties for the encoder
side) and source code is C89 so it must be compilable (libopus) in
almost any platform without a titanic effort.

mp3 is not free?

According with

https://en.wikipedia.org/wiki/MP3#Licensing.2C_ownership_and_legislation

It's royalty free in European Union. And, in USA, still valid patents
will expire along 2017. After 31 December 2017 will be completely
royalty free in USA also.

Don't know rest of the world. Can it be worse than in USA?



Hello,

You are right, my working with MP3 technology was in 1999 so my 
"standards" are very old :-)


Anyway Fraunhofer Institute which holds most known patents about MPEG 
Layer III does not say "Patents expired" so maybe they can have a later 
patent over technology trying to enforce it in a future and keep control 
of the royalties.


Releasing a mp3 codec now could be safe in Europe (and 2018 in EEUU) but 
a hardware piece could be a problem if a later patent appears in the 
game. In the other hand as all known patents has expired I think no 
court will be against you, maybe a "cease and desists" at most.


Anyway mp3 technology is surpassed a lot by others.
--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc and voip ?

2017-02-02 Thread Santiago A.
El 17/01/2017 a las 16:48, José Mejuto escribió:
>
> Maybe you may think in Opus http://opus-codec.org/ as it is open,
> royalty free (mp3 is not free, you must pay royalties for the encoder
> side) and source code is C89 so it must be compilable (libopus) in
> almost any platform without a titanic effort.
mp3 is not free?

According with

https://en.wikipedia.org/wiki/MP3#Licensing.2C_ownership_and_legislation

It's royalty free in European Union. And, in USA, still valid patents
will expire along 2017. After 31 December 2017 will be completely
royalty free in USA also.

Don't know rest of the world. Can it be worse than in USA?

-- 
Saludos

Santiago A.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc and voip ?

2017-02-02 Thread Leonardo M . Ramé
Hi freedvs, does it mean with UOS I can create an audio streaming server via 
HTTP?.
Regards,
Leonardo M. Ramé 
http://leonardorame.blogspot.com

  From: fredvs 
 To: fpc-pascal@lists.freepascal.org 
 Sent: Thursday, February 2, 2017 10:19 AM
 Subject: Re: [fpc-pascal] fpc and voip ?
   
Hello.

I am happy to announce that uos does internet-streaming with opus files.
Take a look at conswebstream and simplewebplayer demos.

https://github.com/fredvs/uos

Here demo (ok, the sound is not perfect because the video recorded the sound
from the mic, but in real the sound is perfect):

https://sites.google.com/site/fredvsbinaries/uos_opus_web.mp4

Enjoy.

Fre;D






-
Many thanks ;-)
--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/fpc-and-voip-tp5727307p5727556.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


   ___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc and voip ?

2017-02-02 Thread fredvs
Hello.

I am happy to announce that uos does internet-streaming with opus files.
Take a look at conswebstream and simplewebplayer demos.

https://github.com/fredvs/uos

Here demo (ok, the sound is not perfect because the video recorded the sound
from the mic, but in real the sound is perfect):

https://sites.google.com/site/fredvsbinaries/uos_opus_web.mp4

Enjoy.

Fre;D






-
Many thanks ;-)
--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/fpc-and-voip-tp5727307p5727556.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] for loop vs while loop

2017-02-02 Thread Mark Morgan Lloyd

On 01/02/17 20:30, Nitorami wrote:

Just a note - I learned that for very short "for" loops it may be even a bit
faster to count downwards (to zero) rather than upwards if possible, because
the comparison to zero is very effiicient. Not sure though whether that
still makes a difference on modern processors.


Testing that on fpc 3.0.0 x86, compiled with -O4 but without looking at 
the generated code:



program test1;

const   top = $7fff;

var a, i: longint;

begin
  for i := 0 to top do
a := i;
  writeln(a)
end.

real0m4.353s
user0m3.284s
sys 0m0.000s


program test2;
  for i := top downto 0 do
a := i;

real0m4.449s
user0m3.256s
sys 0m0.000s


program test3;
  for i := top downto 0 do
a := top - i;

real0m4.671s
user0m3.264s
sys 0m0.000s


It's interesting that the real (wallclock) and user times are 
consistently in a different sequence. /If/ the user time is to be 
believed, there's a very small advantage to counting down even if the 
sequence you want is ascending (i.e. test3) rather than simply counting up.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal