Skip to content

No update of float when writing json after first (few) tracks. #3758

Answered by vitoyucepi
gAlleb asked this question in Q&A
Discussion options

You must be logged in to vote

You should add some kind of safeguard.

def float.json_safe(number)
  list.mem(abs(number), [infinity, nan]) ? null() : number
end

def source.stats(source)
  {
    is_fallible = source.fallible,
    is_ready = source.is_ready(),
    is_up = source.is_up(),
    is_active = source.is_active(),
    is_self_sync = source.self_sync(),
    clock_time = source.time(),
    remaining = float.json_safe(source.remaining()),
    duration = float.json_safe(source.duration()),
    elapsed = source.elapsed(),
  }
end

def write_json(s)
  def write_data()
    data = json.stringify(source.stats(s), compact=true) ^ "\n"
    file.write("/m.json", data=data)
  end

  thread.run(write_data, every=.1, fast=false)

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@gAlleb
Comment options

@gAlleb
Comment options

@gAlleb
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@gAlleb
Comment options

@toots
Comment options

@vitoyucepi
Comment options

Answer selected by gAlleb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants