Example #1
0
void appl::GlyphDecoration::setItalic(bool _enable) {
	m_italic = _enable;
	if (_enable == true) {
		APPL_VERBOSE("color : \"" << m_colorName << "\" enable italic");
	} else {
		APPL_VERBOSE("color : \"" << m_colorName << "\" disable italic");
	}
}
Example #2
0
void appl::GlyphDecoration::setBold(bool _enable) {
	m_bold = _enable;
	if (_enable == true) {
		APPL_VERBOSE("color : \"" << m_colorName << "\" enable bold");
	} else {
		APPL_VERBOSE("color : \"" << m_colorName << "\" disable bold");
	}
}
Example #3
0
void appl::TextViewer::onCallbackselectNewFile(const std::string& _value) {
	APPL_INFO("Select new file: " << _value);
	if (isSelectedLast() == false) {
		return;
	}
	
	// reset scroll:
	if (m_buffer != nullptr) {
		m_buffer->signals.disconnect(sharedFromThis());
		bool needAdd = true;
		auto it = m_drawingRemenber.begin();
		while (it != m_drawingRemenber.end()) {
			ememory::SharedPtr<appl::Buffer> tmpBuff = it->first.lock();
			if (tmpBuff == nullptr) {
				it = m_drawingRemenber.erase(it);
				continue;
			}
			if (tmpBuff == m_buffer) {
				it->second = m_originScrooled;
				APPL_VERBOSE("store origin : " << m_originScrooled);
				needAdd = false;
				break;
			}
			++it;
		}
		if (needAdd == true) {
			m_drawingRemenber.push_back(std::make_pair(ememory::WeakPtr<appl::Buffer>(m_buffer), m_originScrooled));
			APPL_VERBOSE("Push origin : " << m_originScrooled);
		}
	}
	m_originScrooled = vec2(0,0);
	if (m_bufferManager != nullptr) {
		m_buffer = m_bufferManager->get(_value);
		m_bufferManager->setBufferSelected(m_buffer);
		if (m_buffer != nullptr) {
			m_buffer->signalIsModify.connect(sharedFromThis(), &appl::TextViewer::onCallbackIsModify);
			m_buffer->signalSelectChange.connect(sharedFromThis(), &appl::TextViewer::onCallbackSelectChange);
			for (auto element : m_drawingRemenber) {
				if (element.first.lock() == m_buffer) {
					m_originScrooled = element.second;
					APPL_VERBOSE("retrive origin : " << m_originScrooled);
					// TODO : Check if this element is not out of the display text ...
					break;
				}
			}
		}
	}
	markToRedraw();
	return;
}
Example #4
0
// TODO : optimise this with retaine the display position buffer and his position in the real view ...
appl::Buffer::Iterator appl::TextViewer::getMousePosition(const vec2& _relativePos) {
	char32_t currentValue;
	vec3 positionCurentDisplay(0,0,0);
	vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
	int32_t countColomn = 0;
	std::u32string stringToDisplay;
	m_displayText.clear();
	m_displayText.forceLineReturn();
	positionCurentDisplay = m_displayText.getPos();
	for (appl::Buffer::Iterator it = m_buffer->begin();
	     (bool)it == true;
	     ++it) {
		currentValue = *it;
		if (currentValue == u32char::Return) {
			m_displayText.forceLineReturn();
			countColomn = 0;
		} else {
			if (-_relativePos.y() >= positionCurentDisplay.y()) {
				m_buffer->expand(countColomn, currentValue, stringToDisplay);
				for (size_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
					if (stringToDisplay[kkk] == u32char::Return) {
						m_displayText.forceLineReturn();
						countColomn = 0;
					} else {
						//note : Without this condithion the time od selection change to 0.6 ms to 8ms ...
						//APPL_DEBUG("check : " << -_relativePos.y() << ">=" << positionCurentDisplay.y());
						m_displayText.printChar(stringToDisplay[kkk]);
						++countColomn;
					}
				}
			}
		}
		if (-_relativePos.y() >= positionCurentDisplay.y()) {
			if (-_relativePos.y() < positionCurentDisplay.y()+tmpLetterSize.y()) {
				APPL_VERBOSE("line position : '" << (char)(*it) << "' = '" << stringToDisplay << "' n=" << countColomn << " " <<positionCurentDisplay.x() << " < " << _relativePos.x() << " < " << m_displayText.getPos().x() );
				if (    _relativePos.x() >= positionCurentDisplay.x()
				     && _relativePos.x() < m_displayText.getPos().x() ) {
					APPL_VERBOSE("find ...");
					return it;
				}
			} else {
				// previous line ...
				return --it;
			}
		}
		positionCurentDisplay = m_displayText.getPos();
	}
	return m_buffer->end();
}
Example #5
0
// TODO : Update process time ==> a little expensive (2->4ms) in end of file
void appl::TextViewer::updateScrolling() {
	if (m_buffer == nullptr) {
		return;
	}
	vec2 realCursorPosition(0,0);
	uint32_t lineId = m_buffer->getCursorLinesId();
	m_displayText.clear();
	m_displayText.forceLineReturn();
	float lineSize = -m_displayText.getPos().y();
	for (size_t iii=0; iii<lineId; ++iii) {
		m_displayText.forceLineReturn();
	}
	realCursorPosition.setY(-m_displayText.getPos().y());
	realCursorPosition.setX(getScreenSize(m_buffer->getStartLine(m_buffer->cursor()), m_buffer->cursor()));
	APPL_VERBOSE("position=" << realCursorPosition << " scrool=" << m_originScrooled << " size" << m_size);
	if (realCursorPosition.x() < m_originScrooled.x()+lineSize*2.0f) {
		m_originScrooled.setX(realCursorPosition.x()-lineSize*2.0f);
	} else if (realCursorPosition.x() > m_originScrooled.x()+(m_size.x()-m_lastOffsetDisplay)-lineSize*2.0f-10) {
		m_originScrooled.setX(realCursorPosition.x()-(m_size.x()-m_lastOffsetDisplay)+lineSize*2.0f+10);
	}
	if (realCursorPosition.y() < m_originScrooled.y()+lineSize*2.0f) {
		m_originScrooled.setY(realCursorPosition.y()-lineSize*2.0f);
	} else if (realCursorPosition.y() > m_originScrooled.y()+m_size.y()-lineSize*2.0f) {
		m_originScrooled.setY(realCursorPosition.y()-m_size.y()+lineSize*2.0f);
	}
	m_originScrooled.setMax(vec2(0,0));
	// TODO : Limit min position too ...
}
Example #6
0
bool appl::Highlight::isCompatible(const std::string& _name) {
	for (auto &it : m_listExtentions) {
		APPL_DEBUG("        check : " << it << "=?=" << _name);
		std::regex expression;
		try {
			expression.assign(it, std::regex_constants::optimize | std::regex_constants::ECMAScript);
		} catch (std::regex_error e) {
			APPL_ERROR("can not parse regex : '" << e.what() << "' for : " << it);
			continue;
		}
		std::smatch resultMatch;
		std::regex_search(_name.begin(), _name.end(), resultMatch, expression, std::regex_constants::match_continuous);
		if (resultMatch.size() <= 0) {
			continue;
		}
		APPL_VERBOSE("    - begin=" << std::distance(_name.begin(), resultMatch[0].first) << "  end=" << std::distance(_name.begin(), resultMatch[0].second));
		if (resultMatch[0].first != _name.begin()) {
			continue;
		}
		if (resultMatch[0].second != _name.end()) {
			continue;
		}
		return true;
	}
	return false;
}
Example #7
0
appl::GlyphDecoration::GlyphDecoration(const std::string &_newColorName) :
  m_colorName(_newColorName),
  m_colorFG(etk::color::black),
  m_colorBG(etk::color::none),
  m_italic(false),
  m_bold(false) {
	APPL_VERBOSE("create");
}
Example #8
0
void appl::BufferManager::requestDestroyFromChild(const ememory::SharedPtr<Object>& _child) {
	APPL_WARNING("Buffer request a close...");
	bool find = false;
	int32_t newValue = -1;
	auto it = m_list.begin();
	while(it != m_list.end()) {
		if (*it == nullptr) {
			it = m_list.erase(it);
			continue;
		}
		if (*it == _child) {
			it = m_list.erase(it);
			find = true;
			break;
		}
		newValue++;
		++it;
	}
	if (find == true) {
		signalRemoveBuffer.emit(ememory::dynamicPointerCast<appl::Buffer>(_child));
	}
	if (m_bufferSelected == _child) {
		if (    it != m_list.end()
		     && *it != nullptr) {
			APPL_VERBOSE("Remove buffer select new one");
			signalSelectFile.emit((*it)->getFileName());
			propertySetOnWidgetNamed("appl-widget-display-name", "value", etk::FSNodeGetRealName((*it)->getFileName()));
			APPL_VERBOSE("Remove buffer select new one (done)");
			return;
		}
		if (    m_list.size() != 0
		     && m_list.back() != nullptr) {
			APPL_VERBOSE("Remove buffer select new one (last)");
			signalSelectFile.emit(m_list.back()->getFileName());
			propertySetOnWidgetNamed("appl-widget-display-name", "value", etk::FSNodeGetRealName(m_list.back()->getFileName()));
			APPL_VERBOSE("Remove buffer select new one (done)");
			return;
		}
		signalSelectFile.emit("");
		propertySetOnWidgetNamed("appl-widget-display-name", "value", "---");
		m_bufferSelected = nullptr;
	}
}
Example #9
0
int main(int _argc, const char** _argv) {
	// the only one init for etk:
	etk::init(_argc, _argv);
	std::string fbName = "";
	std::string micName = "";
	int32_t filterSize = 0;
	float mu = 0.0f;
	bool nlms = false;
	bool perf = false;
	int64_t sampleRate = 48000;
	for (int32_t iii=0; iii<_argc ; ++iii) {
		std::string data = _argv[iii];
		if (etk::start_with(data,"--fb=")) {
			fbName = &data[5];
		} else if (etk::start_with(data,"--mic=")) {
			micName = &data[6];
		} else if (etk::start_with(data,"--filter-size=")) {
			data = &data[14];
			filterSize = etk::string_to_int32_t(data);
		} else if (etk::start_with(data,"--mu=")) {
			data = &data[5];
			mu = etk::string_to_float(data);
		} else if (data == "--nlms") {
			nlms = true;
		} else if (data == "--perf") {
			perf = true;
		} else if (etk::start_with(data,"--sample-rate=")) {
			data = &data[14];
			sampleRate = etk::string_to_int32_t(data);
		} else if (    data == "-h"
		            || data == "--help") {
			APPL_INFO("Help : ");
			APPL_INFO("    ./xxx --fb=file.raw --mic=file.raw");
			APPL_INFO("        --fb=YYY.raw        Feedback file");
			APPL_INFO("        --mic=XXX.raw       Microphone file");
			APPL_INFO("        --filter-size=xxx   Size of the filter");
			APPL_INFO("        --mu=0.xx           Mu value -1.0< mu < -1.0");
			APPL_INFO("        --nlms              NLMS version");
			APPL_INFO("        --perf              Enable performence test (little slower but real performence test)");
			APPL_INFO("        --sample-rate=XXXX  Signal sample rate (default 48000)");
			exit(0);
		}
	}
	if (    fbName == ""
	     || micName == "") {
		APPL_ERROR("Can not Process missing parameters...");
		exit(-1);
	}
	APPL_INFO("Read FeedBack:");
	std::vector<int16_t> fbData = etk::FSNodeReadAllDataType<int16_t>(fbName);
	APPL_INFO("    " << fbData.size() << " samples");
	APPL_INFO("Read Microphone:");
	std::vector<int16_t> micData = etk::FSNodeReadAllDataType<int16_t>(micName);
	APPL_INFO("    " << micData.size() << " samples");
	// resize output :
	std::vector<int16_t> output;
	output.resize(std::min(fbData.size(), micData.size()), 0);
	// process in chunk of 256 samples
	int32_t blockSize = 256;
	// end filter :
	std::vector<float> filter;
	std11::chrono::nanoseconds totalTimeProcessing(0);
	std11::chrono::nanoseconds minProcessing(99999999999999LL);
	std11::chrono::nanoseconds maxProcessing(0);
	int32_t totalIteration = 0;
	if (nlms == false) {
		APPL_INFO("***********************");
		APPL_INFO("**         LMS       **");
		APPL_INFO("***********************");
		audio::algo::aec::Lms algo;
		if (filterSize != 0) {
			algo.setFilterSize(filterSize);
		}
		if (mu != 0.0f) {
			algo.setMu(mu);
		}
		int32_t lastPourcent = -1;
		for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
			if (lastPourcent != 100*iii / (output.size()/blockSize)) {
				lastPourcent = 100*iii / (output.size()/blockSize);
				APPL_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
			} else {
				APPL_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
			}
			std11::chrono::steady_clock::time_point timeStart = std11::chrono::steady_clock::now();
			algo.process(&output[iii*blockSize], &fbData[iii*blockSize], &micData[iii*blockSize], blockSize);
			if (perf == true) {
				std11::chrono::steady_clock::time_point timeEnd = std11::chrono::steady_clock::now();
				std11::chrono::nanoseconds time = timeEnd - timeStart;
				minProcessing = std::min(minProcessing, time);
				maxProcessing = std::max(maxProcessing, time);
				totalTimeProcessing += time;
				totalIteration++;
				usleep(10000);
			}
		}
		filter = algo.getFilter();
	} else {
		APPL_INFO("***********************");
		APPL_INFO("**    NLMS (power)   **");
		APPL_INFO("***********************");
		audio::algo::aec::Nlms algo;
		if (filterSize != 0) {
			algo.setFilterSize(filterSize);
		}
		int32_t lastPourcent = -1;
		for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
			if (lastPourcent != 100*iii / (output.size()/blockSize)) {
				lastPourcent = 100*iii / (output.size()/blockSize);
				APPL_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
			} else {
				APPL_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
			}
			algo.process(&output[iii*blockSize], &fbData[iii*blockSize], &micData[iii*blockSize], blockSize);
		}
		filter = algo.getFilter();
	}
	if (perf == true) {
		APPL_INFO("Performance Result: ");
		APPL_INFO("    blockSize=" << blockSize << " sample");
		APPL_INFO("    min=" << minProcessing.count() << " ns");
		APPL_INFO("    max=" << maxProcessing.count() << " ns");
		APPL_INFO("    avg=" << totalTimeProcessing.count()/totalIteration << " ns");
		
		APPL_INFO("    min=" << (float((minProcessing.count()*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
		APPL_INFO("    max=" << (float((maxProcessing.count()*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
		APPL_INFO("    avg=" << (float(((totalTimeProcessing.count()/totalIteration)*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
	}
	etk::FSNodeWriteAllDataType<int16_t>("output.raw", output);
	etk::FSNodeWriteAllDataType<float>("filter.raw", filter);
	
}