int main(int argc, char *agrv[]) { google::ParseCommandLineFlags(&argc, &agrv, true); hal::MatrixIOBus bus; if (!bus.Init()) return false; if (!bus.IsDirectBus()) { std::cerr << "Kernel Modules has been loaded. Use ALSA examples " << std::endl; } int sampling_rate = FLAGS_sampling_frequency; hal::MicrophoneArray mics; mics.Setup(&bus); mics.SetSamplingRate(sampling_rate); mics.ShowConfiguration(); // Microphone Core Init hal::MicrophoneCore mic_core(mics); mic_core.Setup(&bus); hal::Everloop everloop; everloop.Setup(&bus); hal::EverloopImage image1d(bus.MatrixLeds()); int j = 0; uint64_t instantE = 0; uint64_t avgEnergy = 0; std::valarray<uint64_t> localAverage(20); localAverage = 0; while (true) { mics.Read(); /* Reading 8-mics buffer from de FPGA */ instantE = 0; for (uint32_t s = 0; s < mics.NumberOfSamples(); s++) { instantE = instantE + (mics.At(s, 0)) * (mics.At(s, 0)); } localAverage[j % 20] = instantE; avgEnergy = 0; for (auto &data : localAverage) { avgEnergy = (avgEnergy + data); } avgEnergy = avgEnergy / 20; for (auto &led : image1d.leds) { led.red = avgEnergy >> 24; } everloop.Write(&image1d); j++; } return 0; }
void HyperbolicSolver< Mesh, SolverType >:: solveOneTimeStep () { // Total number of elements in the mesh const UInt meshNumberOfElements ( M_FESpace.mesh()->numElements() ); // Loop on all the elements to perform the fluxes for ( UInt iElem (0); iElem < meshNumberOfElements; ++iElem ) { // Update the property of the current element M_FESpace.fe().update ( M_FESpace.mesh()->element ( iElem ), UPDATE_QUAD_NODES | UPDATE_WDET | UPDATE_PHI ); // Reconstruct step of the current element localReconstruct ( iElem ); // Evolve step of the current element localEvolve ( iElem ); // Put the total flux of the current element in the global vector of fluxes assembleVector ( *M_globalFlux, M_FESpace.fe().currentLocalId(), M_localFlux, M_FESpace.refFE().nbDof(), M_FESpace.dof(), 0 ); // Average step of the current element localAverage ( iElem ); } // Assemble the global hybrid vector. M_globalFlux->globalAssemble(); // Update the value of the solution (*M_u) = (*M_uOld) - M_data.dataTime()->timeStep() * (*M_globalFlux); // Clean the vector of fluxes M_globalFlux.reset ( new vector_Type ( M_FESpace.map(), Repeated ) ); // Update the solution at previous time step *M_uOld = *M_u; } // solveOneStep