Exemplo n.º 1
0
int main()
{
	int x,y;
	board A[b_][b_];
	Array_Setup(A);
	do
	{
		V_Array_setup(A);
		for(y=0;y<b_;y++)
		{
			for(x=0;x<b_;x++)
			{
				if(A[y][x].real == (b_ * b_))
				{
					printf("*\t");
				}
				else
				{
					printf("%i\t",A[y][x].real);
				}
			}
			printf("\n\n\n");
		}
		printf("\n\n\n");
		printf("\n\n\n");
		printV(A);
		printf("\n\n\n");
		printf("\n\n\n");
		input(A);
		system("cls");
		printf("\n\n\n");
	}while(-1);
	return 0;
}
// _______________________________________________________
void KeyWordDetector::generateWindowFunction() {
  computeWindow(window, WINDOW_LENGTH, FFT_WIN_TYP_HAMMING);
  
  // Compute window normalisation factors (weighing factors)
  for (int i = 0; i < WINDOW_LENGTH/2; i++){
    windowNormS1 += window[i];
    windowNormS2 += pow(window[i], 2);
  }
  // Multiply by two because we only store half of the window
  windowNormS1 *= 2;
  windowNormS2 *= 2;
  
  // Power spectrum scale is for perfomance resons calculated only once
  powerSpectrumScale = 1.0f;
  //powerSpectrumScale = 2/(pow(windowNormS1, 2));
  
#ifdef DEBUG_KD_WINDOW
  Serial.println("Window:");
  printV(window, WINDOW_LENGTH/2, true);
  Serial.print("Window normalisation: S1: ");
  Serial.print(windowNormS1);
  Serial.print(", S2: ");
  Serial.println(windowNormS2);
  Serial.print("PowerSpectrumScale: ");
  Serial.println(powerSpectrumScale);
#endif
}
Exemplo n.º 3
0
static void
error (Info_t* ip, Site* s, float x, float y)
{
    fprintf (stderr, "Unsorted vertex list for site %d (%.16f,%.16f), pt (%f,%f)\n",
        s->sitenbr, s->coord.x, s->coord.y, x, y);
    printV (ip->verts);
}
Exemplo n.º 4
0
void DotFont::print() const
{
	if (_index == _pattern_length)
		this->clear(false);
	else
		_vertical ? printV() : printH();
}
Exemplo n.º 5
0
void printKevin(int x, int y) {
	printK(x,y);
	printE(x+4*SIZE+GAP,y);
	printV(x+7*SIZE+2*GAP,y);
	printI(x+11*SIZE+3*GAP,y);
	printN(x+12*SIZE+4*GAP,y);
}
Exemplo n.º 6
0
void printDevina(int x, int y) {
	printD(x,y);
	printE(x+4*SIZE+GAP,y);
	printV(x+7*SIZE+2*GAP,y);
	printI(x+11*SIZE+3*GAP,y);
	printN(x+12*SIZE+4*GAP,y);
	printA(x+16*SIZE+5*GAP,y);
}
Exemplo n.º 7
0
int main(){

unsigned int i;
std::vector<int> first;
first.push_back(1);
first.push_back(2);
/*first.push_back(3);
first.push_back(4);
first.push_back(5);
first.push_back(6);
first.push_back(7);*/
printV(first);
std::vector<int> reverseV=reverse(first);
printV(reverseV);
reverseV=reverse(first);

std::vector<int> reverseVO=reverse(first);
printV(reverseVO);
}
Exemplo n.º 8
0
void printGameOver(int x, int y) {
	printG(x,y);
	printA(x+5*SIZE+GAP, y);
	printM(x+8*SIZE+2*GAP, y);
	printE(x+13*SIZE+3*GAP, y);
	printO(x+16*SIZE+5*GAP, y);
	printV(x+20*SIZE+6*GAP, y);
	printE(x+24*SIZE+7*GAP, y);
	printR(x+27*SIZE+8*GAP, y);
}
Exemplo n.º 9
0
template <typename ValT> template <typename T> BsTree<ValT>::BsTree(T v) {
  std::sort(v.begin(), v.end());
  printV(v);

  // Use mid element as root, to balance the tree
  root = new Node((ValT)v[v.size() / 2]);
  v.erase(v.begin() + v.size() / 2);

  for (auto el : v)
    insert(el);
}
// _______________________________________________________
void KeyWordDetector::generateMelFilterBank() {
  // Generate mel points
  int arraySize = NUM_MEL_FILTER_BANKS+2;
  float* mel = melPoints(MEL_MIN_FREQUENCY, MEL_MAX_FREQUENCY, NUM_MEL_FILTER_BANKS);
  // Calculate frequencies of this mel points
  float* freq = melsToFrequencies(mel, arraySize);
  // Map the frequencies to bins
  frequenciesToBins(melBins, freq, arraySize, FFT_SIZE, SAMPLING_RATE);
   
  #ifdef DEBUG_KD_MEL
    Serial.print("Mel-Scaled Points:\n");
    printV(mel, arraySize, true);
    Serial.print("Mel-Scaled Frequencies:\n");
    printV(freq, arraySize, true);
    Serial.print("FFT Bins:\n");
    printV(melBins, arraySize, true);
  #endif
  
  // Only the melbins are required, free the rest
  free(freq);
  free(mel);
}
// _______________________________________________________
void KeyWordDetector::performFFT() {
  // Apply the windowing on the vector
  //applyWindowing(vReal, window, WINDOW_LENGTH, true);
 // Apply the windowing on the vector
 // TODO: Seems to work way better without windowing (but why?)
 /*
 for (int i = 0; i < WINDOW_LENGTH/2; i++) {
    vReal[i] *= window[i];
    vReal[WINDOW_LENGTH - (i + 1)] *= window[i];
 
  } */
 
 
 
  // Padd with 0s at the end if FFT size is not the same as windowLength and reset imaginary vector
  for (size_t i = 0; i < FFT_SIZE; i++) {
    if (i >= WINDOW_LENGTH) vReal[i] = 0;
    vImag[i] = 0;
  }
  
  
  // Compute FFT (is done inPlace)
  computeFFT(vReal, vImag, FFT_SIZE);
  
  
  // Get the magnitude of the complex value (inPlace)
  //complexToMagnitude(vReal, vImag, FFT_SIZE);
  // Get the magnitude of the complex value and store in powerSpec 
  complexToMagnitude(vReal, vImag, powerSpec, FFT_SIZE);
  
  #ifdef DEBUG_KD_MAJOR_FREQUENCY
    // Compute the major peak for DEBUG_KDging
    double peak = majorPeak(vReal, FFT_SIZE, SAMPLING_RATE);
    Serial.print("Major peak at: ");
    Serial.print(peak);
    Serial.println("Hz");
  #endif

  #ifdef DEBUG_KD_FFT
    printV(vReal, FFT_SIZE, false);
    Serial.print("\n");
  #endif
}
Exemplo n.º 12
0
void dumpCalibration()
{
    printString("V=" CHEALI_CHARGER_VERSION_STRING);
    printNL();
    printV('E',0,CHEALI_CHARGER_EEPROM_CALIBRATION_VERSION);
    printV('E',1,CHEALI_CHARGER_EEPROM_PROGRAMDATA_VERSION);
    printV('E',2,CHEALI_CHARGER_EEPROM_SETTINGS_VERSION);

    AnalogInputs::CalibrationPoint p;
    FOR_ALL_PHY_INPUTS(it) {
        AnalogInputs::getCalibrationPoint(p,it,0);
        printV('a',it, p.x);
        printV('r',it, p.y);
        AnalogInputs::getCalibrationPoint(p,it,1);
        printV('A',it, p.x);
        printV('R',it, p.y);
    }
}
Exemplo n.º 13
0
void printPage(const byte clientsel, const byte deviceIdx) {

	// Index
	printP(clientsel, TXTIND);
	printP(clientsel, TXTCOLON);
	printV(clientsel, deviceIdx);
	printP(clientsel, ANBSP);

	// DeviceID
	printP(clientsel, TXTDEVICEID);
	printP(clientsel, TXTCOLON);
	printV(clientsel, mdevices[deviceIdx].getDeviceID());

	// Type
	printP(clientsel, ANBSP);
	if (mdevices[deviceIdx].getType() != 0) {
		printP(clientsel, TXTTYPE);
		printP(clientsel, TXTCOLON);
		printV(clientsel, mdevices[deviceIdx].getType());
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
	}

	// CommandID
	printP(clientsel, TXTCOMMAND );
	printP(clientsel, TXTCOLON);
	printVstr(clientsel, mdevices[deviceIdx].getCommand());

	// Status
	printP(clientsel, ANBSP);
	printP(clientsel, TXTSTATUS );
	printP(clientsel, TXTCOLON);
	printVstr(clientsel, mdevices[deviceIdx].getStatus());

	// Value
	if (mdevices[deviceIdx].commandValue != 0) {
		printP(clientsel, ANBSP);
		printP(clientsel, TXTVALUE );
		printP(clientsel, TXTCOLON);
		printVstr(clientsel, mdevices[deviceIdx].getValue());
	}

	// ExtData
	if (printVstr(clientsel, mdevices[deviceIdx].getExtData(), true) > 0) {
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
		printP(clientsel, TXTEXTDATA );
		printP(clientsel, TXTCOLON);
		printVstr(clientsel, mdevices[deviceIdx].getExtData());
	}


	printP(clientsel, AOPEN);
	printP(clientsel, BR);
	printP(clientsel, SLASH);
	printP(clientsel, ACLOSE);
	if (EEPROMReadInt(PARAMS(deviceIdx, 1)) !=  FFFF) {
		// Parameter 1
		printP(clientsel, TXTPAR1);
		printP(clientsel, TXTCOLON);
		printV(clientsel, EEPROMReadInt(PARAMS(deviceIdx, 1)));
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
	}
	if (EEPROMReadInt(PARAMS(deviceIdx, 2)) !=  FFFF) {
		// Parameter 2
		printP(clientsel, TXTPAR2);
		printP(clientsel, TXTCOLON);
		printV(clientsel, EEPROMReadInt(PARAMS(deviceIdx, 2)));
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
	}
	if (EEPROMReadInt(PARAMS(deviceIdx, 3)) !=  FFFF) {
		// Parameter 3
		printP(clientsel, TXTPAR3);
		printP(clientsel, TXTCOLON);
		printV(clientsel, EEPROMReadInt(PARAMS(deviceIdx, 3)));
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
	}
	if (EEPROMReadInt(PARAMS(deviceIdx, 4)) !=  FFFF) {
		// Parameter 3
		printP(clientsel, TXTPAR4);
		printP(clientsel, TXTCOLON);
		printV(clientsel, EEPROMReadInt(PARAMS(deviceIdx, 4)));
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
	}
	if (EEPROMReadInt(PARAMS(deviceIdx, 5)) !=  FFFF) {
		// Parameter 5
		printP(clientsel, TXTPAR5);
		printP(clientsel, TXTCOLON);
		printV(clientsel, EEPROMReadInt(PARAMS(deviceIdx, 5)));
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
	}

	// In deviceIdx
	if (mdevices[deviceIdx].getInput() != 0) {
		printP(clientsel, TXTDEVIND);
		printP(clientsel, TXTCOLON);
		printV(clientsel, mdevices[deviceIdx].getInput());
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
	}

	// Pin
	if (mdevices[deviceIdx].getPin() != 0) {
		printP(clientsel, TXTPIN);
		printP(clientsel, TXTCOLON);
		printV(clientsel, mdevices[deviceIdx].getPin());
		printP(clientsel, AOPEN);
		printP(clientsel, BR);
		printP(clientsel, SLASH);
		printP(clientsel, ACLOSE);
	}


	if (DEBUG_WEB) dbg.println();

	return;
}
Exemplo n.º 14
0
int printResponse(const byte clientsel, const byte deviceIdx, const bool getLen = false) {

	int len = 0;

	len += printP(clientsel, TXTSBRACKETOPEN, getLen);

	// DeviceID
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printP(clientsel, TXTDEVICEID, getLen);
	printP(clientsel, TXTQUOTE, getLen);
	len += printP(clientsel, TXTCOLON, getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printV(clientsel, mdevices[deviceIdx].getDeviceID(), getLen);
	len += printP(clientsel, TXTQUOTE, getLen);

	// CommandID
	len += printP(clientsel, TXTCOMMA, getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printP(clientsel, TXTCOMMAND , getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printP(clientsel, TXTCOLON, getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printVstr(clientsel, mdevices[deviceIdx].getCommand(), getLen);
	len += printP(clientsel, TXTQUOTE, getLen);

	// Status
	len += printP(clientsel, TXTCOMMA, getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printP(clientsel, TXTSTATUS , getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printP(clientsel, TXTCOLON, getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printVstr(clientsel, mdevices[deviceIdx].getStatus(), getLen);
	len += printP(clientsel, TXTQUOTE, getLen);

	// Value
	if (mdevices[deviceIdx].commandValue != 0) {
		len += printP(clientsel, TXTCOMMA, getLen);
		len += printP(clientsel, TXTQUOTE, getLen);
		len += printP(clientsel, TXTVALUE , getLen);
		len += printP(clientsel, TXTQUOTE, getLen);
		len += printP(clientsel, TXTCOLON, getLen);
		len += printP(clientsel, TXTQUOTE, getLen);
		len += printVstr(clientsel, mdevices[deviceIdx].getValue(), getLen);
		len += printP(clientsel, TXTQUOTE, getLen);
	}

	// InOut
	len += printP(clientsel, TXTCOMMA, getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printP(clientsel, TXTINOUT , getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printP(clientsel, TXTCOLON, getLen);
	len += printP(clientsel, TXTQUOTE, getLen);
	len += printVstr(clientsel, "1", getLen);
	len += printP(clientsel, TXTQUOTE, getLen);

	// ExtData
	if (printVstr(clientsel, mdevices[deviceIdx].getExtData(), true) > 0) {
		len += printP(clientsel, TXTCOMMA, getLen);
		len += printP(clientsel, TXTQUOTE, getLen);
		len += printP(clientsel, TXTEXTDATA , getLen);
		len += printP(clientsel, TXTQUOTE, getLen);
		len += printP(clientsel, TXTCOLON, getLen);
		len += printVstr(clientsel, mdevices[deviceIdx].getExtData(), getLen);
	}

	len += printP(clientsel, TXTSBRACKETCLOSE, getLen);

	if (DEBUG_WEB) dbg.println();

	return len+1;			// WHYYYYYYYYYYYY was not needed before refactor on 1/13/2015
}
Exemplo n.º 15
0
void DotChar::print() const {
    if (_index == _df.length)
        this->clear(false);
    else
        _vertical ? printV() : printH();
}
Exemplo n.º 16
0
std::string Terrain::setup()
{
	std::string empty = "> No file!";
	glm::vec3 top = glm::vec3(0, 1, 0);

	if (fileExists(tname) == true) {
		std::cout << "> Initializing file...\n";
		return tname;
	}
	else {

		int numc = rand() % 2048000;

		num = std::pow(2, sizes);

		int sn = num / 2;
		int yy = miny;

		int total = num * num * 3;

		int length = 0;
		int width = 0;

		float precision = precise;
		maxy *= precision;

		std::cout << "> Generating plane...\n";

		for (float loop = -sn; loop <= sn + num; loop += precision) {
			std::vector <glm::vec3> store;

			float x = loop;
			float y;
			float z;

			float r = rand() % 2;

			for (float loopy = -sn; loopy <= sn; loopy += precision) {
				glm::vec3 temp;

				z = loopy;
				float p = randFloat(miny, maxy);
				float s = rand() % 16;

				if (s > avg) {
					y = p;
				}
				else {
					y = miny;
				}

				temp.x = x;
				temp.y = y;
				temp.z = z;

				store.push_back(temp);
			}

			length = store.size();
			full.push_back(store);

		}

		width = full.size();

		//std::cout << full.max_size() << std::endl;

		int pt1 = 1;
		int pt2 = length + 1;
		int pt3 = 2;

		int next1 = length + 2;
		int next2 = 3;

		int indicesA = width * length;
		int ctrl = (length + 1) * (width + 1);
		ctrlamount = ctrl;

		std::vector <glm::vec3> cpoints;
		glm::vec3 meh;

		for (int u = 0; u < full.size(); u++) {
			std::vector <glm::vec3> temp = full.at(u);
			for (int q = 0; q < temp.size(); q++) {
				glm::vec3 tmp = temp.at(q);
				cpoints.push_back(tmp);
				meh = tmp;
			}
		}

		std::vector <glm::vec3> cnormals;

		//((num + 3) * (num + 2));

		std::cout << "> Generating points...\n> Total points: " << cpoints.size() << "\n";
		normals.push_back(top);

		for (int i = 0; i < ctrl; i++) {

			if (i == 0) {
				indices.push_back(pt1);
				//cnormals.push_back(cpoints.at(pt1));
				indices.push_back(pt2);
				//cnormals.push_back(cpoints.at(pt2));
				indices.push_back(pt3);
				//cnormals.push_back(cpoints.at(pt3));
			}
			else if (next2 % length == 0) {
				next1 += 1;
				next2 += length;

				indices.push_back(next1);
				//cnormals.push_back(cpoints.at(next1));
				indices.push_back(next2);
				//cnormals.push_back(cpoints.at(next2));

				next1 -= length - 1;
				next2 -= length - 1;

				indices.push_back(next1);
				//cnormals.push_back(cpoints.at(next1));
				indices.push_back(next2);
				//cnormals.push_back(cpoints.at(next2));

				next1 += length;
				next2 += 1;

			}
			else if (i == ctrl - 1) {
				indices.push_back(next1);
				//cnormals.push_back(cpoints.at(next1));
				indices.push_back(next2);
				//cnormals.push_back(cpoints.at(next2));
			}
			else {
				indices.push_back(next1);
				//cnormals.push_back(cpoints.at(next1));
				indices.push_back(next2);
				//cnormals.push_back(cpoints.at(next2));

				next1 += 1;
				next2 += 1;

			}

		}

		std::cout << "> Generating normals...\n";

		std::vector <glm::vec3> fnormals;

		glm::vec3 cache1;
		glm::vec3 cache2;
		glm::vec3 cache3;

		/*
		for (int o = 0; o < cnormals.size() - 2; o++) {
			cache1 = cnormals.at(o);
			cache2 = cnormals.at(o + 1);
			cache3 = cnormals.at(o + 2);

			if (o % 3 == 0) {
				fnormals.push_back(computeNormal(cache1, cache2, cache3));
			}

		}
		*/

		if (isFile == true) {

			std::string s1 = std::to_string(sizes);
			std::string s2 = std::to_string(precise);
			std::string s3 = std::to_string(numc);

			std::string all = "./res/worlds/" + tname + "." + s1 + "_" + s2 + "_" + s3 + ".obj";

			std::ofstream file(all);
			file.close();

			file.open(all);

			std::cout << "> Writing to file...\n";

			//file << "# " << Display::getTime();
			master.append("# " + Display::getTime());

			//file << "# " << "Made by PathFinder v0.0.5" << "\n\n";
			master.append("# Made by PathFinder v0.0.5\n\n");

			for (int lp = 0; lp < full.size(); lp++) {
				std::vector <glm::vec3> tp = full.at(lp);

				for (int lpp = 0; lpp < tp.size(); lpp++) {
					//file << "v" << printV(tp.at(lpp));
					master.append("v" + printV(tp.at(lpp)));

				}
			}

			//file << "vt " << 0.000000 << "1.000000\n";
			master.append("vt 0.000000 1.000000\n");

			//file << "vn " << "0 " << "1 " << "0\n";
			//master.append("vn" + printV(top));

			for (int x = 0; x < normals.size(); x++) {
				master.append("vn" + printV(normals.at(x)));
			}

			for (int a = 0; a <= ctrl; a++) {
				int r = 1;//rand() % 4 + 1;

						  //file << "f " << indices.at(a) << "/1" << "/" << r << " " << indices.at(a + 1) << "/1" << "/" << r
						  //	 << " " << indices.at(a + 2) << "/1" << "/" << r << "\n";

				std::string e1 = std::to_string(indices.at(a));
				std::string e2 = std::to_string(indices.at(a + 1));
				std::string e3 = std::to_string(indices.at(a + 2));
				std::string e4 = std::to_string(r);

				master.append("f " + e1 + "/1/" + e4 + " " + e2 + "/1/" + e4 + " " + e3 + "/1/" + e4 + "\n");

			}

			file << master;

			std::cout << "> Generated size: " << indices.size() << "\n";

			file.close();

			return all;
		}
		else {
			std::cout << "> Transferring world...\n";
			return empty;
		}

	}

}