Re: Are there any ALSA Perl Modules?

2024-01-29 Thread sisyphus
On Mon, Jan 29, 2024 at 6:28 AM Martin McCormick 
wrote:
   [snip]

> I may be looking in the wrong places but, so far, I seem
> to be batting zeros when looking for perl and alsa together.
>

I take it that MIDI::ALSA  (https://metacpan.org/pod/MIDI::ALSA) has little
or nothing to offer ?

Cheers,
Rob


Re: Are there any ALSA Perl Modules?

2024-01-29 Thread Olivier
Shlomi Fish  writes:

>>  Anyway, the FFI concept will probably someday come in
>> handy for a different project so I will continue with the C I was
>> working on.

What I did in a project is having the main functionality written in C,
but using Perl for things that could be handy like parsing a config file
(lot of text, regex, etc.) or calling outside script that could be
written independently from the main code.

Best luck,

Olivier

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Are there any ALSA Perl Modules?

2024-01-29 Thread Shlomi Fish
hi Martin,

On Mon, 29 Jan 2024 22:38:27 -0600
"Martin McCormick"  wrote:

> Shlomi Fish  writes:
> > hi Martin,
> > you can try using an FFI, eg:
> > 
> > https://metacpan.org/dist/Inline-C/view/lib/Inline/C.pod
> > 
> > https://metacpan.org/dist/Inline-Python/view/Python.pod
> > 
> > https://metacpan.org/pod/FFI::Platypus  
> 
> Many thanks.  I am glad I asked the question but it has taken me
> some time to digest your answer as I wasn't familiar with the
> term FFI so, after exercising duckduckgo, I now know those
> letters stand for Foreign Function Interface which makes perfect
> sense based on what needs to be done.  Unfortunately, FFI's are
> usually used by higher-level languages to take advantage of the
> capabilities found in lower-level languages such as C which is
> closer to assembler and can efficiently access the hardware such
> as an audio or video device.
> 

I meant that you can use Inline::C or perlxs or similar to write
wrappers/bindings for libalsa/etc.

>   I was hoping there might be a perl module like a
> fictional one I will call Device::ALSA which would understand the
> syntax used in capturing audio from a microphone or line input,
> like a microphone input, only not as sensitive, where one
> customarily feeds sound from the output of whatever one is
> recording from.
> 
>   There are standard alsa conventions for setting sample
> rate and other parameters which I mentioned in the earlier
> posting so if one knows what sort of digital stream they nead,
> they just stuff those values in to the function whose output is
> that stream of digital  data.  What you do with those data is up
> to you but the module takes care of getting the bits from the
> hardware or sending the bits to your speakers or headphones and
> would also support the alsa plugins which are used by the arecord
> and aplay utilities for added capabilities.
> 
>   I can understand why there is no perl module like
> Device::alsa because it would not be portable between Windows and
> Linus.  The l in alsa is for Linux so basically, I was just
> curious to see if anything like Device::ALSA existed and it
> apparently does not exist.
> 

Devs *have* written linux-only or mswindows-only perl5/CPAN modules.

>   Anyway, the FFI concept will probably someday come in
> handy for a different project so I will continue with the C I was
> working on.
> 
>   Thanks again.
> 
> Martin
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
https://www.shlomifish.org/open-source/resources/tech-tips/

XSLT isn't like violence. XSLT is violence - there is no such thing as using
it too little.
— https://www.shlomifish.org/humour/bits/facts/XSLT/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Are there any ALSA Perl Modules?

2024-01-29 Thread Martin McCormick
Shlomi Fish  writes:
> hi Martin,
> you can try using an FFI, eg:
> 
> https://metacpan.org/dist/Inline-C/view/lib/Inline/C.pod
> 
> https://metacpan.org/dist/Inline-Python/view/Python.pod
> 
> https://metacpan.org/pod/FFI::Platypus

Many thanks.  I am glad I asked the question but it has taken me
some time to digest your answer as I wasn't familiar with the
term FFI so, after exercising duckduckgo, I now know those
letters stand for Foreign Function Interface which makes perfect
sense based on what needs to be done.  Unfortunately, FFI's are
usually used by higher-level languages to take advantage of the
capabilities found in lower-level languages such as C which is
closer to assembler and can efficiently access the hardware such
as an audio or video device.

I was hoping there might be a perl module like a
fictional one I will call Device::ALSA which would understand the
syntax used in capturing audio from a microphone or line input,
like a microphone input, only not as sensitive, where one
customarily feeds sound from the output of whatever one is
recording from.

There are standard alsa conventions for setting sample
rate and other parameters which I mentioned in the earlier
posting so if one knows what sort of digital stream they nead,
they just stuff those values in to the function whose output is
that stream of digital  data.  What you do with those data is up
to you but the module takes care of getting the bits from the
hardware or sending the bits to your speakers or headphones and
would also support the alsa plugins which are used by the arecord
and aplay utilities for added capabilities.

I can understand why there is no perl module like
Device::alsa because it would not be portable between Windows and
Linus.  The l in alsa is for Linux so basically, I was just
curious to see if anything like Device::ALSA existed and it
apparently does not exist.

Anyway, the FFI concept will probably someday come in
handy for a different project so I will continue with the C I was
working on.

Thanks again.

Martin

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Are there any ALSA Perl Modules?

2024-01-28 Thread Shlomi Fish
hi Martin,

On Sun, 28 Jan 2024 13:27:45 -0600
"Martin McCormick"  wrote:

> Several years ago, I wrote some C code which turns one's
> computer's sound interface in to a sound-activated recorder that
> I could then connect to radio receivers or microphones and record
> when audio started and stop recording when there is nothing but
> silence.  One essentially sets a sound card to record
> continuously but the sound samples go through code that knows
> what silence looks like.  In short, silence looks like samples
> whose numeric value is exactly half-way between the lowest and
> highest voltage that the analog-to-digital converter reads,
> commonly either 32,767 representing silence, give or take a count
> or two due to digital sampling errors or decimal 128, hex 80 for
> 8-bit mono audio.
> 
>   The Advanced Linux Sound Architecture Project has C library
> functions for setting sample rates, mono, stereo, big or little
> endianness and 8 or 16-bit audio, whatever one needs for their
> application.  One can even define samples as signed or unsigned
> integers.
> 
>   Once one gets a stream of ints which are usually 32-bits
> wide for stereo or 16-bit shorts for mono, the sound processing
> can begin which C is really good at but perl is just as good at
> so if one could get the same alsa modules which are used by aplay
> and arecord for setting up one's audio interfaces or sound cards,
> the manipulation of those data that was done in C could also be
> done in perl without hardly any modification to it at all.
> 
>   Perl has just the right mix of low-level logic and
> bitwise operators plus a much more easy-to-use string handling
> capability which is why I am asking this question.
> 
>   I may be looking in the wrong places but, so far, I seem
> to be batting zeros when looking for perl and alsa together.
>

you can try using an FFI, eg:

https://metacpan.org/dist/Inline-C/view/lib/Inline/C.pod

https://metacpan.org/dist/Inline-Python/view/Python.pod

https://metacpan.org/pod/FFI::Platypus
 
>   Any good ideas are greatly appreciated, here.
> 
>   Martin McCormick
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
Selina Mandrake - The Slayer (Buffy parody) - https://shlom.in/selina

If the miller travelled to the market with Emma, they would have each rided
their own donkey. Problem solved.
— https://www.shlomifish.org/humour/bits/facts/Emma-Watson/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Are there any ALSA Perl Modules?

2024-01-28 Thread hw
On Sun, 2024-01-28 at 13:27 -0600, Martin McCormick wrote:
> [...]
>   I may be looking in the wrong places but, so far, I seem
> to be batting zeros when looking for perl and alsa together.
> 
>   Any good ideas are greatly appreciated, here.

I would think that one nowadays would use (go through) pipewire for
anything that involves recording and playing sounds.

I've no clue how that would work, though.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/