1. Vitalie Matvei
  2. Digital Audio & Music Computers
  3. Friday, 28 February 2020
  4.  Subscribe via email
All about creating the tools for editing music on the computer.
Accepted Answer Pending Moderation
I want to start this topic with a little and very interesting program → Calculate the frequency of a MIDI Note number. How we can know, each musical note has the own frequency and a MIDI number. For example, Midi note number 73(C#5) has frequency 554.365262 Hz.
https://www.inspiredacoustics.com/en/MIDI_note_numbers_and_center_frequencies

This program is written in the C program language and has the following code.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>

int main()
{
    double c5, c0, semitoe_ratio, frequency;
    int midinote;
    char message[256];
    char *result;

    semitoe_ratio = pow(2, 1.0 / 12);
    c5 = 220.0 * pow(semitoe_ratio, 3);
    c0 = c5 * pow(0.5, 5);

    printf("Enter MIDI note (0 - 127): ";);
    result = gets(message);
    if (result == NULL)
    {
        printf("There was an error reading the input.\n";);
        return 1;
    }
    if (message[0] == '\0')
    {
        printf("Have a nice day!\n";);
        return 1;
    }
    midinote = atoi(message);
    if (midinote < 0)
    {
        printf("Sorry - %s is a bad MIDI note number\n", message);
        return 1;
    }
    if (midinote > 127)
    {
        printf("Sorry - %s is beyound the MIDI range!\n", message);
        return 1;
    }

    frequency = c0 * pow(semitoe_ratio, midinote);
    printf("frequeny of MIDI note %d = %f\n", midinote, frequency);

    getch();
    return 0;
}

midi2freq.jpg


Also, I put here the midi2freq.exe program for windows.
Attachments (2)
  1. more than a month ago
  2. # 1
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!