element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Cirrus Logic - RPI 2 FFT on streaming audio
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 14 replies
  • Answers 2 answers
  • Subscribers 676 subscribers
  • Views 1719 views
  • Users 0 members are here
  • wolfson
  • logic
  • raspberry
  • python
  • audio
  • pi
  • cirrus
  • 2
  • raspberry_pi
  • fft
  • raspeberry_pi_accessories
  • card
Related

Cirrus Logic - RPI 2 FFT on streaming audio

Former Member
Former Member over 10 years ago

Hi everyone,

My current project is to run constant FFT on an audio stream and output the data to a 3D LED Array. Google 3D LED cubes if you don't know what they are. My cube is more of a rectangular prism, 24x8x8=1536 LED's. I am new to the world of PI and have found the support for the cirrus logic card to be vague, if it wasn't for ppl like ragnar.jensen I'd probably still be stuck (thanks for all the information you've shared).

 

Anyway, currently I am recording 1 second of audio after a 1 second delay. So it takes 2 seconds to get the data / audio.

 

I then perform the FFT on 16384 samples. But this is only 1/3 of the 44000 raw audio samples recorded in the 1 second interval. I then group the frequencies into bands and then scale the amplitudes of those bands into a single byte which represents the bands power. The result of each FFT is 24 bytes, one byte for each band. All this takes 0.1 second.@@@@@

 

It then takes 0.004 seconds to send that data to my PIC, which I had to bit bang through the GPIO's since I couldn't get I2C or UART working.

 

The LED array takes the data and displays the 24x8 bits on the front row, when it receives the next group of data the front row shifts back one row. The LED array displays 3 dimensions, time (each group of data), frequencies and amplitude.

 

Question:

In the arecord command, I would like to erase the delay or change it to 0 seconds and change the minimum record length so I can stream the data at a faster rate to the LED array. Does anybody know how????

 

Answering this would result in a real time graphics equalizer on live audio and a more fluent transition between groups of data (more like a wave travelling away from you).

 

If anybody has an idea on how to achieve this please reply, or share your thoughts.

  • Sign in to reply
  • Cancel
Parents
  • balearicdynamics
    0 balearicdynamics over 10 years ago

    Hello Daniel,

     

    I found this on a different forum but I don't know how to use it.

     

    I took a look to the mentioned library available on GitHub: http://stackoverflow.com/questions/29839082/capture-record-audio-in-linux-for-milliseconds

    Despite the excessive simplification I am sadly used reading by the experts of stackoverflow, these piece of code are almost interesting as released under source so you can eventually change and adapt to your needs without big difficulties interfacing them. You should consider it as a simplifying interface between Alsa - that is, a library - and your program. The point IMHO is not the math but the fact that in a multithreaded environment without a real time kernel you risk to have unpredictable delays due the other common processes Linux is running by itself (at least). If you are using Cirrus Logic audio on Raspberry PI2 I suppose you have installed a real time version of Raspbian, is correct? I have done so and despite the limitations in the update / upgrade possibilities (that are not available after this version of kernel is running) I have experienced that solved a lot of problems.

     

    There is another factor that I suggest you to consider; the audio source should be also played or should just only managed by a mathematical point of view? In this second case I think that the Alsa library should be sight by a different point of view as what you need in this case is a robust data acquisition system and probably real-time processing of the data generating the visual audio you will provide.

     

    Let me know. Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to balearicdynamics

    Hi Enrico,

                   Thank you very much for sharing your thoughts I agree with you on many things, such as- all I require is a robust data acquisition system. It just needs to capture live data, perform math and output the result. I do not need a GUI, applications and sub processes that I don't even realize are running. On a side note: I originally chose the raspberry Pi for this project for 3 reasons, its cheap, its fast enough to perform the calculation, there appeared to be lots of support/resources for me to learn from and achieve my goal.

    Currently I am using a standard kernel, but I intend on attempting to use a real time kernel once I can capture audio in frames determined by milliseconds or number of samples. Like you said, once you change to real time kernel there are limitations on updates. So I wanted to achieve my goals in the most common environment that the community uses. I am taking tiny little baby steps!

     

    I tried to compile main.cc (from Waxo's library on GitHub), using geany, but this failed. I am not sure why, perhaps geany needs to be configured to compile c++ instead of c? Could you point me in the right direction about things I should learn or do?

     

    After that attempt, I tried to edit the source file "aplay.c" as mentioned in that forum. So I downloaded all the ALSA utils and libraries I could find as compiling aplay.c includes files which include other files.

    Within aplay.c, the start_delay was easy enough to find, I simply changed it to 0 on lines 119,505 and 651

                          the record duration was a bit more difficult to find. I believe it is in the sub routine, static void capture(char *orig_name) under the variable count,, could be wrong. (around line 2926)

    In any case I could not compile aplay.c either

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • balearicdynamics
    0 balearicdynamics over 10 years ago in reply to Former Member

    Hi Daniel,

     

    I have already experienced a similar problem using the CL for data processing in the Meditech project. One of the difficulties is to download the RT Linux for PI. I have a copy and if you need I can send you it by private email just because I have searched it again recently and I have not found image

     

    About the issues on the RT Kernel specific for the CL and some details I have published some articles in past that I will link below. More details I can find in my local archives.

     

    Meditech: Microphonic stethoscope

    Cirrus Logic Audio Card: audio monitor while recording

    Meditech: Text-To-Speech user support

     

    Here and there in these posts there are some useful information, links and also good comments from the other valuable guys. For more detailed information let me know because to have the stuff working I had to do a lot of research and tests and I have saved almost all the documentation.

     

    Hope this can help.

     

    Enrico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • scitechindian
    0 scitechindian over 10 years ago in reply to balearicdynamics

    awesome reply image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • scitechindian
    0 scitechindian over 10 years ago in reply to balearicdynamics

    awesome reply image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube