Autore: mhm

Play streaming radio in bash

 

mplayer http://listen.radionomy.com/deejayfoxradiostation

alias swr1='alsaplayer http://mp3-live.swr.de/swr1bw_s.m3u &' alias swr1rp='alsaplayer http://mp3-live.swr.de/swr1rp_s.m3u &' alias swr2='alsaplayer http://mp3-live.swr.de/swr2_s.m3u &' alias swr3='alsaplayer http://mp3-live.swr3.de/swr3_s.m3u &' alias swr4='alsaplayer http://mp3-live.swr.de/swr4bw_s.m3u &' alias swr4rp='alsaplayer http://mp3-live.swr.de/swr4rp_s.m3u &' alias swrcontra='alsaplayer http://mp3-live.swr.de/contra_s.m3u &' alias swrcontrahd='alsaplayer http://swr.ic.llnwd.net/stream/swr_mp3_m_contraa $ alias radio='echo swr1 swr2 swr3 swr4 swrcontra swrcontrahd' alias quiet='killall alsaplayer'

 


http://crunchbang.org/forums/viewtopic.php?id=12085

https://wiki.ubuntuusers.de/Internetradio/Stationen/

 

Kernel – Debugging by printing

Probably the simplest way to get some debug information from your kernel code

printk("My Debugger is Printk\n");

just like in userspace.In order to see the kernel messages, just use the

$ dmesg

ALSA project – the C library reference

Typedefs

typedef struct _snd_hctl_elem snd_hctl_elem_t
typedef struct _snd_hctl snd_hctl_t
typedef int(* snd_hctl_compare_t )(const snd_hctl_elem_t *e1, const snd_hctl_elem_t *e2)
Compare function for sorting HCTL elements.
typedef int(* snd_hctl_callback_t )(snd_hctl_t *hctl, unsigned int mask, snd_hctl_elem_t *elem)
HCTL callback function.
typedef int(* snd_hctl_elem_callback_t )(snd_hctl_elem_t *elem, unsigned int mask)
HCTL element callback function.

Functions

int snd_hctl_compare_fast (const snd_hctl_elem_t *c1, const snd_hctl_elem_t *c2)
A “don’t care” fast compare functions that may be used with snd_hctl_set_compare.
int snd_hctl_open (snd_hctl_t **hctl, const char *name, int mode)
Opens an HCTL.
int snd_hctl_open_ctl (snd_hctl_t **hctlp, snd_ctl_t *ctl)
Opens an HCTL.
int snd_hctl_close (snd_hctl_t *hctl)
close HCTL handle
int snd_hctl_nonblock (snd_hctl_t *hctl, int nonblock)
set nonblock mode
int snd_hctl_poll_descriptors_count (snd_hctl_t *hctl)
get count of poll descriptors for HCTL handle
int snd_hctl_poll_descriptors (snd_hctl_t *hctl, struct pollfd *pfds, unsigned int space)
get poll descriptors
int snd_hctl_poll_descriptors_revents (snd_hctl_t *ctl, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
get returned events from poll descriptors
unsigned int snd_hctl_get_count (snd_hctl_t *hctl)
Get number of loaded elements for an HCTL.
int snd_hctl_set_compare (snd_hctl_t *hctl, snd_hctl_compare_t hsort)
Change HCTL compare function and reorder elements.
snd_hctl_elem_t * snd_hctl_first_elem (snd_hctl_t *hctl)
get first element for an HCTL
snd_hctl_elem_t * snd_hctl_last_elem (snd_hctl_t *hctl)
get last element for an HCTL
snd_hctl_elem_t * snd_hctl_find_elem (snd_hctl_t *hctl, const snd_ctl_elem_id_t *id)
Search an HCTL element.
void snd_hctl_set_callback (snd_hctl_t *hctl, snd_hctl_callback_t callback)
Set callback function for an HCTL.
void snd_hctl_set_callback_private (snd_hctl_t *hctl, void *data)
Set callback private value for an HCTL.
void * snd_hctl_get_callback_private (snd_hctl_t *hctl)
Get callback private value for an HCTL.
int snd_hctl_load (snd_hctl_t *hctl)
Load an HCTL with all elements and sort them.
int snd_hctl_free (snd_hctl_t *hctl)
free HCTL loaded elements
int snd_hctl_handle_events (snd_hctl_t *hctl)
Handle pending HCTL events invoking callbacks.
const char * snd_hctl_name (snd_hctl_t *hctl)
get identifier of HCTL handle
int snd_hctl_wait (snd_hctl_t *hctl, int timeout)
Wait for a HCTL to become ready (i.e. at least one event pending)
snd_ctl_t * snd_hctl_ctl (snd_hctl_t *hctl)
Get a ctl handle associated to the given hctl handle.
snd_hctl_elem_t * snd_hctl_elem_next (snd_hctl_elem_t *elem)
get next HCTL element
snd_hctl_elem_t * snd_hctl_elem_prev (snd_hctl_elem_t *elem)
get previous HCTL element
int snd_hctl_elem_info (snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info)
Get information for an HCTL element.
int snd_hctl_elem_read (snd_hctl_elem_t *elem, snd_ctl_elem_value_t *value)
Get value for an HCTL element.
int snd_hctl_elem_write (snd_hctl_elem_t *elem, snd_ctl_elem_value_t *value)
Set value for an HCTL element.
int snd_hctl_elem_tlv_read (snd_hctl_elem_t *elem, unsigned int *tlv, unsigned int tlv_size)
Get TLV value for an HCTL element.
int snd_hctl_elem_tlv_write (snd_hctl_elem_t *elem, const unsigned int *tlv)
Set TLV value for an HCTL element.
int snd_hctl_elem_tlv_command (snd_hctl_elem_t *elem, const unsigned int *tlv)
Set TLV value for an HCTL element.
snd_hctl_t * snd_hctl_elem_get_hctl (snd_hctl_elem_t *elem)
Get HCTL handle for an HCTL element.
void snd_hctl_elem_get_id (const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr)
Get CTL element identifier of a CTL element id/value.
unsigned int snd_hctl_elem_get_numid (const snd_hctl_elem_t *obj)
Get element numeric identifier of a CTL element id/value.
snd_ctl_elem_iface_t snd_hctl_elem_get_interface (const snd_hctl_elem_t *obj)
Get interface part of CTL element identifier of a CTL element id/value.
unsigned int snd_hctl_elem_get_device (const snd_hctl_elem_t *obj)
Get device part of CTL element identifier of a CTL element id/value.
unsigned int snd_hctl_elem_get_subdevice (const snd_hctl_elem_t *obj)
Get subdevice part of CTL element identifier of a CTL element id/value.
const char * snd_hctl_elem_get_name (const snd_hctl_elem_t *obj)
Get name part of CTL element identifier of a CTL element id/value.
unsigned int snd_hctl_elem_get_index (const snd_hctl_elem_t *obj)
Get index part of CTL element identifier of a CTL element id/value.
void snd_hctl_elem_set_callback (snd_hctl_elem_t *obj, snd_hctl_elem_callback_t val)
Set callback function for an HCTL element.
void * snd_hctl_elem_get_callback_private (const snd_hctl_elem_t *obj)
Get callback private value for an HCTL element.
void snd_hctl_elem_set_callback_private (snd_hctl_elem_t *obj, void *val)
Set callback private value for an HCTL element.

 


http://www.alsa-project.org/alsa-doc/alsa-lib/group___h_control.html

 

Speex encode in a file using python

I'm using the script found on this blog Google speech recognition with python (I give any credit to author).

 import sys
    import pyaudio, speex
    import numpy as np  # just for doing a standard deviation for audio level checks
    import urllib2
    import wave

    e = speex.Encoder()
    e.initialize(speex.SPEEX_MODEID_WB)
    d = speex.Decoder()
    d.initialize(speex.SPEEX_MODEID_WB)

    chunk = 320 # tried other numbers... some don't work
    FORMAT = pyaudio.paInt16
    bytespersample=2
    CHANNELS = 1
    RATE = 16000 # "wideband" mode for speex. May work with 8000. Haven't tried it.

    p = pyaudio.PyAudio()

    # Start the stream to record the audio
    stream = p.open(format = FORMAT,
                    channels = CHANNELS,
                    rate = RATE,
                    input = True,
                    output = True,
                    frames_per_buffer = chunk)

    print "Listening. Recording will start when some sound is heard."

    threshold = 200  # Adjust this to be slightly above the noise level of your recordings.
    nquit = 40 # number of silent frames before terminating the program
    nover = 0
    keepgoing = True
    spxlist=[]  # list of the encoded speex packets/frames
    while keepgoing:
      data = stream.read(chunk) # grab 320 samples from the microphone
      spxdata = e.encode(data) # encode using the speex dll
      print "Length encoded: %d"%len(spxdata) # print the length, after encoding. Can't exceed 255!
      spxlist.append(spxdata)
      a=np.frombuffer(data,np.int16) # convert to numpy array to check for silence or audio
      audiolevel=np.std(a)
      if audiolevel < threshold:  # too quiet
        nover+=1
      else:
        nover=0

      if nover >= nquit:
        keepgoing=False


      print '%2.1f (%d%% quiet)'%(audiolevel, nover*100/nquit)

    print "Too quiet. I'm stopping now."
    stream.stop_stream()
    stream.close()
    p.terminate()
    fullspx=''.join(spxlist)  # make a string of all the header-ized speex packets
    out_file = open("test.spx","wb")
    out_file.write(fullspx)
    out_file.close()

 


http://stackoverflow.com/questions/12528962/output-speex-encode-in-a-file-using-python

http://campus.albion.edu/squirrel/2012/03/01/google-speech-recognition-with-python/

cubieboard.org Einstein-A20, A unlimited potential Embeded Computer Module

Just like the previous announcement,  Cubietech will operate another product category other than Cubieboard series, we call it Einstein series. It’s also a relatively complete computer module, but with more potential feature expanding ability. Now we deliver the first member of this family Einstein-A20. With this product, the small company and start-up team can finish their prototypes very quickly and even run production with no trouble. Below is some preview photoes, I hope you will like it…

Einstein-A20-appearance-5


http://cubieboard.org/2015/05/28/preview-of-einstein-a20-a-unlimited-potential-embeded-computer-module/