arduino-audio-tools
Time.h
1 #pragma once
3 #include <iostream>
4 #include <thread>
5 
6 // #ifndef DESKTOP_MILLIS_DEFINED
7 // #define DESKTOP_MILLIS_DEFINED
8 
9 namespace audio_tools {
10 
12 inline uint32_t millis(){
13  using namespace std::chrono;
14  // Get current time with precision of milliseconds
15  auto now = time_point_cast<milliseconds>(system_clock::now());
16  // sys_milliseconds is type time_point<system_clock, milliseconds>
17  using sys_milliseconds = decltype(now);
18  // Convert time_point to signed integral type
19  return now.time_since_epoch().count();
20 }
21 
22 // sleep ms milliseconds
23 void delay(unsigned long ms){
24  std::this_thread::sleep_for(std::chrono::milliseconds(ms));
25 }
26 
27 // sleep us milliseconds
28 void delayMicroseconds(unsigned int us){
29  std::this_thread::sleep_for(std::chrono::microseconds(us));
30 }
31 
32 // Returns the micros of milliseconds passed since epich
33 inline unsigned long micros(void){
34  using namespace std::chrono;
35  // Get current time with precision of milliseconds
36  auto now = time_point_cast<microseconds>(system_clock::now());
37  // sys_milliseconds is type time_point<system_clock, milliseconds>
38  using sys_milliseconds = decltype(now);
39  // Convert time_point to signed integral type
40  return now.time_since_epoch().count();
41 }
42 
43 
44 }
45 
46 // #endif
If you want to use the framework w/o Arduino you need to provide the implementation of a couple of cl...
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AudioConfig.h:872
uint32_t millis()
Returns the milliseconds since the start.
Definition: Time.h:12