Jump to content

  • Log In with Google      Sign In   
  • Create Account


lomateron

Member Since 03 Feb 2012
Offline Last Active Jul 10 2014 02:14 PM
-----

Topics I've Started

solving this kind of jigsaw puzzle using GPU

08 July 2014 - 06:49 PM

Does someone here knows a page that has solutions to this kind of problem?

 

i2plYO8.png


algorithm that predicts how a song continues

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;
}

graphic diagnostics

26 May 2014 - 04:36 PM

I am using windows 7 visual studio 2013 update 2 and directx 10

 

I am using g_pVsgDbg->CaptureCurrentFrame(); to debug some draws

 

the problem is that  g_pVsgDbg->CaptureCurrentFrame(); only captures the draws that are after it

 

is there a way to capture all the draws that are in the frame were g_pVsgDbg->CaptureCurrentFrame(); was called?

 

more exactly I have something like this:

 

drawA();

 

if(SOMETHING)

{

      g_pVsgDbg->CaptureCurrentFrame();

}

 

g_pSwapChain->Present(1, 0);

 

"SOMETHING" depends on "drawA();" so I can't move the condition and I want to debug drawA();


how do you check your code

22 May 2014 - 05:34 PM

when you are going to write code to use the GPU mostly to calculate values that are not related to rendering images

And you have various different steps that depend on each other

what are ways that you have developed to check that every step works correctly


limit on the how many bytes that can be passed across shaders

27 April 2014 - 02:10 AM

In a structure that receives the pixel shader from the vertex shader

what are the limits to the amount of bytes that can be passed?

Any links to a place that describes this?

 

I am asking this because I had this structure

 

struct PS_PAIReduc
{
    float4 Pos : SV_POSITION;
uint MVP[4][3][3] : MASKVALUEPOINTS;
uint Loct : LOCATION;
};
 
But "MVP" could not be created by the compiler so I transformed it to this:
 
struct PS_PAIReduc
{
    float4 Pos : SV_POSITION;
uint3 MVPa[4] : MASKVALUEPOINTSA;
uint3 MVPb[4] : MASKVALUEPOINTSB;
uint3 MVPc[4] : MASKVALUEPOINTSC;
uint Loct : LOCATION;
};
 
but now the compiler is throwing me this error:
 
Error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Mask <and if pixel shader,also interpolation mode> on all input registers in an index range must be identical. Input registers [4] does not match with others in the index range from 1 to 4.
 
I don't understand this,can someone explain me this error?
 

PARTNERS