This section contains the fft part which is used to transform sound signal into color more accurately but due to time and knowledge constraint is sadly unused.
This commit is contained in:
Vindicator645 2018-12-27 10:03:40 +08:00
parent 5b3e2e2640
commit 29fa1a5dd6
9 changed files with 158 additions and 1 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@ -26,6 +26,8 @@ unsigned long fresh_screen(int signal);
//计算函数声明
void draw_fields(int signal);
int create_fields(int hw);
/************************************************
***/

View File

@ -1,6 +1,7 @@
#ifndef type_h
#define type_h
#include <iostream>
#include <stdint.h>
#include <cmath>
@ -11,9 +12,18 @@
#include <GLUT/GLUT.h>
#include <sys/time.h>
#include <unistd.h>
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifdef WIN32
#include <Windows.h>
#include <glut.h>
#pragma warning(disable:4996)
#endif
#include <vector>
#include <list>
#include <map>
#endif /* type_h */
#endif

View File

@ -9,6 +9,7 @@ using std::string;
using std::vector;
FILE * readWAVInfo(void);
int init_test_wav(int);
struct WAV_Format{
uint32_t ChunkID; /* "RIFF" */

View File

@ -1 +1,4 @@
#include <fields.hpp>

View File

@ -3,12 +3,34 @@
#include <wav.hpp>
extern int if_fresh, if_draw;
extern vector<Field*> fields;
extern Window *p_nwd;
extern WAV twav;
extern Shape *p_avg;
#ifdef WIN32
int gettimeofday(struct timeval *tp, void *tzp)
{
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm.tm_isdst = -1;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 1000;
return (0);
}
#endif
void draw_fields(int signal){
if (if_fresh == 1 && if_draw == 0){
timeval timer_a, timer_b;
@ -57,3 +79,17 @@ unsigned long fresh_screen(int signal){
return -1;
}
int create_fields(int hw) {
for (int y = 0; y < hw; y++) {
for (int x = 0; x < hw; x++) {
double dx = x / 16.8, dy = y / 16.8;
Field *p_field = new Field({ {-0.9 + dx,0.9 - dy,0},{-(0.848) + dx,(0.848) - dy,0} });
p_nwd->draw_shape(p_field);
fields.push_back(p_field);
}
}
fields[0]->color.setColor({ 0,0,0 });
p_avg->setRetangle({ {0.98,-0.98},{0.85,-0.85} });
p_nwd->draw_shape(p_avg);
return 0;
}

View File

@ -2,6 +2,8 @@
#include <graphs.hpp>
#include <hsv.hpp>
hsv rgb2hsv(rgb in)
{
hsv out;

View File

@ -1,5 +1,7 @@
#include <wav.hpp>
extern WAV twav;
FILE * readWAVInfo(void){
FILE *fp = NULL;
struct WAV_Format wav;
@ -8,3 +10,10 @@ FILE * readWAVInfo(void){
return fp;
}
int init_test_wav(int ms) {
twav.getInfo();
twav.setTimer(ms);
return sqrt(twav.m_pss.step);
}

31
windows/main.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <type.hpp>
#include <graphs.hpp>
#include <fields.hpp>
#include <wav.hpp>
int if_fresh = 1, if_draw = 0;
list<Shape *> Window::shapes = {};
map<string, View2D *> Window::menus = {};
vector<Field*> fields;
unsigned long fresh_screen(int signal);
FILE *fp;
Window *p_nwd = NULL;
WAV twav("data/test.wav");
Shape *p_avg = new Shape();
int main(int argc, char * argv[]) {
Window nwd(argc, argv);
p_nwd = &nwd;
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(700, 700);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
int hw = init_test_wav(60);
create_fields(hw);
nwd.create("Fields");
nwd.show();
return 0;
}