Skip to content

Instantly share code, notes, and snippets.

View Ziaeemehr's full-sized avatar
💭
Women-Life-Freedom✌️

Abolfazl Ziaee mehr Ziaeemehr

💭
Women-Life-Freedom✌️
View GitHub Profile
@Ziaeemehr
Ziaeemehr / kalimba.py
Last active August 18, 2024 09:55
Convert Kalimba notes CHAR<->NUM
# Function to convert musical notes to numerical values
def convert_notes_to_numbers(notes):
'''
Convert characters to numbers, keeping the punctuation unchanged
Parameters
----------
notes: str - the string of notes to convert
Returns
import numpy as np
x = np.fromfile("X.bin", dtype=float, count=-1)
# dtype: float for double,
# np.uint32 for integer.
// open file as binary:
std::ofstream oX((path + "/X.bin").c_str(), std::ios::out | std::ios::binary);
// write a vector into the file
oX.write((char *)&x[0], x.size() * sizeof x[0]);
// close the file
oX.close();