Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Lukt niet:
Code:git clone git@github.com:StrangeDelight/MiniaudioSample.git Cloning into 'MiniaudioSample'... The authenticity of host 'github.com (140.82.121.4)' can't be established. ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com' (ED25519) to the list of known hosts. git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
git clone https://github.com/StrangeDelight/MiniaudioSample.git
Als dat één van de bij gevoegde samples is dan is het een C# noot. Als je de mono sample afspeelt op 48kHz dan hoor je de werkelijke noot.Ik zit nu met een probleempje: welke gehoorde frequentie kunnen we zinvol aan onderstaand geluid toeschrijven?

git clone https://github.com/StrangeDelight/MiniaudioSample.git metMIDI
// primes2.cpp - the smallest version: no command line, options are constants.
//
// NUM_THREADS threads search the numbers 1..RANGE for primes. Each thread
// gets its own PrimeRange object (its part of the range + a counter).
// While working, every thread stores its progress (0..100 %) in its object
// and the main program keeps drawing one progress bar per thread on screen.
//
// Compile: g++ -std=c++17 -Wall -Wextra -O2 -pthread primes2.cpp -o primes2
// Run: ./primes2
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
const int NUM_THREADS = 10; // how many threads
const int RANGE = 1000000000; // inspect the numbers 1..RANGE
const bool SHOW_PRIMES = false; // true: store and print the primes too
const int BAR_WIDTH = 50; // progress bar columns (1 column = 2 %)
struct PrimeRange {
int low, high; // the part this thread checks (inclusive)
long long count = 0; // primes found
std::vector<int> primes; // the primes themselves (only if SHOW_PRIMES)
std::atomic<int> percent{0}; // progress 0..100; the thread writes it, main
// reads it -> atomic makes that safe
};
bool isPrime(int n)
{
if (n < 2) return false;
for (int d = 2; d * d <= n; ++d)
if (n % d == 0) return false;
return true;
}
void findPrimes(PrimeRange* r) // this is what every thread runs
{
long long size = r->high - r->low + 1;
for (int n = r->low; n <= r->high; ++n) {
if (isPrime(n)) {
++r->count;
if (SHOW_PRIMES) r->primes.push_back(n);
}
int done = (long long)(n - r->low + 1) * 100 / size;
if (done != r->percent) r->percent = done; // report progress
}
r->percent = 100; // also for an empty range
}
// Draw one bar: a full block per 2 %, a half block for an odd 1 %.
void drawBar(int threadNo, int percent)
{
std::cout << "Thread " << (threadNo < 10 ? " " : "") << threadNo << " [";
for (int col = 0; col < BAR_WIDTH; ++col) {
int p = percent - col * 2; // how much of this column is filled: 0, 1 or 2+
std::cout << (p >= 2 ? "█" : p == 1 ? "▌" : " ");
}
std::cout << "] " << (percent < 100 ? " " : "") << (percent < 10 ? " " : "")
<< percent << " %\n";
}
int main()
{
// Divide 1..RANGE over the threads; thread 1 gets the leftovers.
std::vector<PrimeRange> ranges(NUM_THREADS);
int next = 1;
for (int i = 0; i < NUM_THREADS; ++i) {
int size = RANGE / NUM_THREADS + (i == 0 ? RANGE % NUM_THREADS : 0);
ranges[i].low = next;
ranges[i].high = next + size - 1;
next = ranges[i].high + 1;
}
// Start the threads, each with a pointer to its own object.
auto start = std::chrono::steady_clock::now();
std::vector<std::thread> threads;
for (int i = 0; i < NUM_THREADS; ++i)
threads.push_back(std::thread(findPrimes, &ranges[i]));
// Show the progress bars until every thread reports 100 %.
// "\033[<n>A" is the terminal code for "move the cursor n lines up", so
// the bars stay in place and are overwritten instead of scrolling.
// "\033[?25l" hides the cursor (no flickering), "\033[?25h" shows it again.
std::cout << "\033[?25l";
while (true) {
bool allDone = true;
for (int i = 0; i < NUM_THREADS; ++i) {
int p = ranges[i].percent;
drawBar(i + 1, p);
if (p < 100) allDone = false;
}
std::cout << std::flush;
if (allDone) break;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::cout << "\033[" << NUM_THREADS << "A";
}
std::cout << "\033[?25h";
// Wait for the threads (they are done, this just cleans up).
for (std::thread& t : threads)
t.join();
auto stop = std::chrono::steady_clock::now();
// Report.
long long total = 0;
for (int i = 0; i < NUM_THREADS; ++i) {
if (SHOW_PRIMES)
for (int p : ranges[i].primes) std::cout << p << "\n";
std::cout << "Thread " << i + 1 << ": " << ranges[i].low << " .. "
<< ranges[i].high << " -> " << ranges[i].count << " primes\n";
total += ranges[i].count;
}
std::cout << "\nRange 1 .. " << RANGE << " -> " << total << " primes in total\n"
<< "Time: " << std::chrono::duration<double, std::milli>(stop - start).count()
<< " ms\n";
}