This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from types import SimpleNamespace as Namespace | |
import sys | |
# Future function from np_chaonay.main | |
def tmp(err,status_msg=None,IsWarning=False): | |
name=type(err).__name__ | |
if not IsWarning: | |
type_='Error' | |
if status_msg==None: status_msg='Program operation has error due to Python exception.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Name: Main Stopwatch | |
# Description: My main stopwatch program written in Python. | |
# Author: Nuttapong Punpipat (NP-chaonay) | |
# Version: V.2.0.0_beta | |
# Revised Date: 2020-06-23 12:20 (UTC) | |
# License: MIT License | |
# Version Note: | |
# - Major version: indicates of very significant changes or changes that break compatibility on some system/platforms. | |
# - Minor version: indicates of significant changes or features adding. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import objects | |
import numpy as np | |
import pandas as pd | |
import h5py,random | |
# Prepare file | |
path='./Misc/msd_summary_file.h5' | |
hd5_file=h5py.File(path,'r') | |
# Shuffle and get n randomly-selected songs index (on each mode group (Major-Minor)) | |
maj_index=np.where( hd5_file['analysis']['songs']['mode']==0 )[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Get the most n highest-amplitude musical note using my custom algorithm of FFT (on FFT length 35999) on each period (4134 samples) in the arr. | |
### Metadata | |
+ Author : Nuttapong Punpipat (NP-chaonay) | |
+ Updated On : 25/05/2020 at 9:56 UTC | |
+ General Updating Frequency : Weekly | |
+ Code Snippet Completeness : N/A | |
+ Stability : Beta | |
### General Notices |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Create sine wave and write to disk ### | |
import math | |
import numpy as np | |
import scipy.io.wavfile as scp_io_wav | |
rate=44100 | |
freq=440 | |
sample_num=rate*5 | |
# Note: round to 15 due to inaccurate of resulted value when input values "pi" and "2pi" | |
# Note: Using modulus (When at least 1 cycle of circle sine is reached, reset to 0) to prevent bigger value cause the inaccurate of resulted value. (Using lower rounding decimal point may decrease precision when inputted value goes higher.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name : NP-chaonay main module | |
# Description : My module that contains general object for using. | |
# Author : Nuttapong Punpipat (NP-chaonay) | |
# License : MIT License | |
# Language : English | |
# Version / Last Programmed : V.1.0 09/06/20 14:33 (UTC) | |
### TODO ### | |
# - Update this script : Added print_err | |
# - Improve print_err | |
# - Improve another object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (General Properties's Description) | |
# - Type : Available as {Program,Script,Snippet,Module,Project,Library,Docs} | |
# (WARNING) Script and Program Difference: Script is like a Program it is scripting AND it (recommended OR must) be confingured inside the script first. | |
# - Implemented_Language : If more than 1 coding language is used, specify as Multi or specify them | |
# (Python-related Properties's Description) | |
# - PythonInteractive_CopyPaste_Guaranteed : | |
# (Note) For shorten the sentence, define this sentence "executed by copy the whole portion and paste to Python Interactive Console" as the word "that action" | |
# If, all code-contained sections are able to be done that action | |
# Or if, | |
# there're at least 1 code-contained sections that are able to be done that action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Program/Data Initialization ### | |
import urllib.request | |
import pandas as pd | |
import itertools | |
def pandas_series_full_display(series): | |
print('-'*64) | |
for property_i in range(series.count()): | |
print(str(series.index[property_i])+': '+str(series[property_i])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os,glob,random,subprocess,signal,threading,time,sys,curses | |
IsProcessRunning=True | |
Is_cli_win_display_Active=False | |
Has_cli_win_display_Active=False | |
play_no=0 | |
args=['<Not playing>','<Not playing>'] | |
os.chdir('/home/np-chaonay/') | |
songs=[] | |
def curses_print(msg,scr): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import time | |
start=time.time() | |
end=time.time() | |
latency=end-start | |
import signal,subprocess,sys,threading,os,random | |
def is_str_is_integer(string): | |
if string[0]=='-': | |
n=1 | |
else: n=0 |