Beispiel #1
0
Datei: main.c Projekt: robinrob/c
int main(void)
{
	int day, month, year, date;
	printf("Enter a day: ");
	scanf("%d", &day);
	printf("Enter a month: ");
	scanf("%d", &month);
	printf("Enter a year (yy): ");
	scanf("%d", &year);
	date = pack_date(day, month, year);
	printf("\nPacked date: ");
	bit_print(date);
	printf("\n");
	printf("Integer date: %d\n", date);
	printf("Unpacked date: ");
	unpack_date(date);
	printf("\n");
	
	printf("\nNext packed date: ");
	date = next_date(date);
	bit_print(date);
	printf("\n");
	printf("Integer date: %d\n", date);
	printf("Unpacked date: ");
	unpack_date(date);
	printf("\n");
	return 0;
}
Beispiel #2
0
/** @brief Retrieves the next occurring event, or nullptr if none happens before date */
Event* FutureEvtSet::pop_leq(double date, double* value, resource::Resource** resource)
{
  double event_date = next_date();
  if (event_date > date || heap_.empty())
    return nullptr;

  Event* event = heap_.top().second;
  Profile* profile = event->profile;
  DatedValue dateVal = profile->next(event);

  *resource = event->resource;
  *value = dateVal.value_;

  heap_.pop();

  return event;
}
Beispiel #3
0
  static void
  run(float tempo,
      const Control::time_signature& sig,
      ossia::value_port& res,
      ossia::token_request tk,
      ossia::exec_state_facade st)
  {
    if (tk.date > tk.prev_date)
    {
      if (tk.prev_date == 0)
      {
        res.write_value(1, tk.tick_start());
      }

      const auto period
          = get_period(1. / sig.second, (double)tempo, st.sampleRate());
      const auto next = next_date(tk.prev_date, period);
      if (next.impl < tk.date.impl)
      {
        if (sig == Control::time_signature{3, 4})
        {
          ossia::timed_value t;
          if (next.impl == 0 || (next.impl % (3 * period)) == 0)
            res.write_value(1, tk.to_tick_time(next));
          else
            res.write_value(0, tk.to_tick_time(next));
        }
        else if (sig == Control::time_signature{4, 4})
        {
          ossia::timed_value t;
          if (next.impl == 0 || next.impl % (2 * period) == 0)
            res.write_value(1, tk.to_tick_time(next));
          else
            res.write_value(0, tk.to_tick_time(next));
        }
      }
    }
  }