Jump to content

  • Log In with Google      Sign In   
  • Create Account


lomateron

Member Since 03 Feb 2012
Offline Last Active Yesterday, 11:40 AM

#5157778 algorithm that predicts how a song continues

Posted by lomateron on 03 June 2014 - 05:02 AM

I come here again asking for someone with a good CPU to run this code I have created

You give it a .wav file with with 44100 samples per second, 2 channels=stereo, 16 bits per sample

Use songs that are around 30 seconds long

 

This line: std::cout << h << ", " << dataz << "\n";

Is the one that tells the progress, the program finishes when "h" reaches "dataz"

But if you want the code to run faster, delete that line

 

The algorithm uses the first half of the song to predict how the other half continues

It uses only the data of the left channel

 

I use __int64 because they are necessary

#include <stdio.h>
#include <fstream>
#include <iostream>

__int64 wichMate[65536];

int main()
{
	FILE* fp = fopen("a.wav", "rb");
	FILE* FW = fopen("output.wav", "wb");
	short* dutu=0;

	if (fp == NULL)
	{
		return 0;
	}

	char id[5];
	unsigned long size;
	short format_tag, channels, block_align, bits_per_sample;
	unsigned long format_length, sample_rate, avg_bytes_sec, data_size;

	fread(id, sizeof(char), 4, fp);
	fwrite(id, sizeof(char), 4, FW);
	id[4] = '\0';

	if (!strcmp(id, "RIFF"))
	{
		fread(&size, sizeof(unsigned long), 1, fp);
		fread(id, sizeof(char), 4, fp);
		fwrite(&size, sizeof(unsigned long), 1, FW);
		fwrite(id, sizeof(char), 4, FW);
		id[4] = '\0';

		if (!strcmp(id, "WAVE"))
		{
			fread(id, sizeof(char), 4, fp);
			fread(&format_length, sizeof(unsigned long), 1, fp);
			fread(&format_tag, sizeof(short), 1, fp);
			fread(&channels, sizeof(short), 1, fp);
			fread(&sample_rate, sizeof(unsigned long), 1, fp);
			fread(&avg_bytes_sec, sizeof(unsigned long), 1, fp);
			fread(&block_align, sizeof(short), 1, fp);
			fread(&bits_per_sample, sizeof(short), 1, fp);


			fwrite(id, sizeof(char), 4, FW);
			fwrite(&format_length, sizeof(unsigned long), 1, FW);
			fwrite(&format_tag, sizeof(short), 1, FW);
			fwrite(&channels, sizeof(short), 1, FW);
			fwrite(&sample_rate, sizeof(unsigned long), 1, FW);
			fwrite(&avg_bytes_sec, sizeof(unsigned long), 1, FW);
			fwrite(&block_align, sizeof(short), 1, FW);
			fwrite(&bits_per_sample, sizeof(short), 1, FW);

			fread(id, sizeof(char), 4, fp);
			fread(&data_size, sizeof(unsigned long), 1, fp);

			fwrite(id, sizeof(char), 4, FW);
			fwrite(&data_size, sizeof(unsigned long), 1, FW);

			dutu = new short[data_size / 2];
			fread(dutu, 1, data_size, fp);
			fwrite(dutu, 1, data_size / 2, FW);
		}
	}
	fclose(fp);

	data_size /= 4;
	__int64 dataz = __int64(data_size);

	__int64* arrre = new __int64[dataz];
	__int64* mumu = new __int64[dataz];

	for (__int64 i = 0; i < dataz; i++){ mumu[i] = __int64(dutu[i * 2]); arrre[i] = 0; }

	__int64 div = dataz / 2;
	__int64 din = div-1;

	for (__int64 h = 1; h < dataz; h++)
	{
		//std::cout << h << ", " << dataz << "\n";
		__int64 cok = mumu[h];
		
		if (h > din)
		{ 
			__int64 kno = 0;
			for (__int64 g = din - 1; g >= 0; g--)
			{
				arrre[kno] = arrre[kno + 1] + (65536-abs(mumu[g] - cok));
				kno++;
			}
		}
		else
		{
			__int64 kno = 0;
			for (__int64 g = h - 1; g >= 0; g--)
			{
				arrre[kno] += (65536-abs(mumu[g] - cok));
				kno++;
			}
		}

		if (h >= din)
		{
			for (__int64 i = 0; i < 65536; i++)
			{
				wichMate[i] = 0;
			}

			__int64 dede = din;
			for (__int64 i = 0; i < din; i++)
			{
				__int64 luko = mumu[dede] + 32768;
				__int64 mult2 = arrre[i];
				__int64 multt = mult2 * 65535;
				
				for (__int64 n = 0; n < 65536; n++)
				{
					wichMate[n] += multt - (abs(luko - n)*mult2);
				}
				dede--;
			}

			__int64 max = 0;

			for (__int64 i = 1; i < 65536; i++)
			{
				if (wichMate[i] >wichMate[max])
				{
					max = i;
				}
			}

			mumu[h + 1] = max - 32768;
		}
	}
	

	for (__int64 i = div; i < dataz; i++)
	{
		short dni = short(mumu[i]);
		fwrite(&dni, 2, 1, FW);
		fwrite(&dni, 2, 1, FW);
	}

	fclose(FW);

	return 0;
}



#5144935 change 1D addres to 2D addres

Posted by lomateron on 07 April 2014 - 01:10 AM

You could use a Texture1D instead of Texture2D: x is not defined by a texture

Why are w/x always floats?: because that how it is

 

I though you people used this conversion a lot too, and already have one at hand to exchange like:

ohh in nvidia hardware I will use this code... but in AMD ones I will use this one that works anywhere




#5144928 change 1D addres to 2D addres

Posted by lomateron on 07 April 2014 - 12:50 AM

gives 0 answers and wants my topic deleted

 

does someone else thinks this question is not worth an answer




#5144516 who has the biggest score

Posted by lomateron on 05 April 2014 - 12:09 AM

whut, can I know why the downvotes?




#5144464 who has the biggest score

Posted by lomateron on 04 April 2014 - 04:40 PM

In D3D10

I will render around 100,000 vertex with one VertexBuffer of just one vertice using DrawInstanced(), D3D10_PRIMITIVE_TOPOLOGY_POINTLIST

the output of the vertex shader is a random ID the can go from 0 to 2^32, and a random score that can go from 0 to 2^32

Various vertex can output the same ID, the total score of the ID is the sum of all scores with the same ID

I want to know which ID has the highest score, just using the GPU




#5143374 a better computer

Posted by lomateron on 30 March 2014 - 10:35 PM

So the brain is pretty good at thinking because it has a lot of connections between neurons

the limitation is the number of connections, the more the better

when building a computer, is there a way of making one that doesn't has this limit of a physical  "cable" connection between two places?

instead of using "cables" it will use the electromagnetic force, so problems like simulating the gravitational force between particles will be solved in O(1)

does a computer that work in this way has a name?

 




#5133821 data compression

Posted by lomateron on 23 February 2014 - 05:38 AM

"destroy"

I don't think that's a good word, it should be "replace"

replaced by a repetition




#5133816 data compression

Posted by lomateron on 23 February 2014 - 05:05 AM

I will expand:

 

data compression means to move data from the space dimension to the time dimension...

 

So how do you move data from space dimension to the time dimension?

You can't...

 

what can be done is take various different data that is already in time dimension, then combine it in space dimension to get the time data representation of the data in the space dimension, like this

 

7Z4rR4c.png

 

or I could use another clock that has a default 111011

 

what do you think?




#5133807 data compression

Posted by lomateron on 23 February 2014 - 04:35 AM

haegarr

"information can be destroyed simply by leaving it out"

 

you can't prove that, was there information before you were born, is there going to be information after you die?




#5133786 data compression

Posted by lomateron on 23 February 2014 - 03:20 AM

where does the information that you took out when compressing data go?

 

this question just let me discover a better definition of the term data compression than the messed one I had(LOSSLESS COMPRESION)

when data is compressed, the data is moved from the dimension of space into the dimension of time

nws2mOY.png

 

this should be the principal definition of data compression

what do you think?




#5127287 human intelligence

Posted by lomateron on 29 January 2014 - 03:06 PM

Tournicoti what matters here are arguments and his arguments are good.

Intelligence is this: receives input data(zeros and ones), and it predicts what the next input will be given a part of the input data or nothing.

What is wron with this?




#5112318 How select best video card in Direcx automatic with code

Posted by lomateron on 26 November 2013 - 08:13 PM

It's better if you let the user choose which card to use.




#5107172 has anyone here released a game that got no attention and make you depressed...

Posted by lomateron on 05 November 2013 - 09:09 AM

Wait I have not released my game yet, I am just preparing myself mentally, still don't want to show nothing about it, and just wanted to know about other people that have spent same time as me and alone in a game

My last comment was just for the lols, take it lightly


#5107060 has anyone here released a game that got no attention and make you depressed...

Posted by lomateron on 04 November 2013 - 08:26 PM

Ok lols rejected , now serious

 

For me it doesn't matter if you are a starter or not, don't do something that has been done lots of times before

 

Orymus3

Your game needs better artwork, and effects, it feels very old and simple. And I can't see anything new.

SUGGESTION: Add force, momentum, collision physics and make that space fleet more personal by being more physically controllable, add two mouse support: with one mouse you controll the missiles trajectory and with the other the space ship movements, so you will have to move to evade the missiles that are being controlled by the enemy following you and viceversa, then as you progress the speed of the missiles and the fleet increase. So it will be no more strategy...I don't like strategy games.

 

Shade

That game is a metroid with starfox fusion, it has story, animations, models, ai, explosions effects... those takes time to do and the game doen't show something revolutionary in any of those, I will not want to do something that takes time and isn't new.

SUGGESTION: Buy an oculus rift give the game the support, get high, play the game, add to game the visions that you get

 

 

DecadeDesign

Insufficient gameplay, can't say something

SUGGESTION: show some gameplay




#5106600 has anyone here released a game that got no attention and make you depressed...

Posted by lomateron on 02 November 2013 - 09:31 PM

has anyone here spent more than 2 years developing a game alone?

would like to know that game






PARTNERS